I have an Access report. The problem is that it always display an empty row at the end. In the query there are no empty values however the report always shows an empty row. Any ideas?
https://drive.google.com/file/d/0B5XFoGik1WSWUmRkRktla2VIYnM/view?usp=sharing
https://drive.google.com/file/d/0B5XFoGik1WSWcFF3SnZpekVwTlU/view?usp=sharing
On a form I would set "Allow additions" to false. However I don't know what I would do on a report.
A report has an OnNoData event that you could use to cancel the opening of the report. It is often used to popup a message with like "The report, with the specified parameters, would return no data." The code would popup the message, then run a DoCmd.Cancel, or Me.Close acReport, Me.Name.
You can also base the report on a query that has the AllowUpdates set to false (in the QBE, set the properties). Another idea would be to render the report in Preview Mode.
Related
I've got an Access Form with a combobox bound to a query that selects 2 fields. I managed to get the combobox showing up the query's second column by setting up in the combobox's Property Sheet the following: Column Number = 2 (with the first column width = 0); Bound Column = 1 (because it contains a value input for another query).
My problem is that when I open the Form, choose a value from the combobox and then save the Form as a Report, the combobox goes blank! In the Report I don't find the value previously selected for the combobox in the Form.
How can I fix it?
It appears you are looking to give the end user the ability to print what they see on the data entry form. But in access the printing functions are attached to reports. So we need a report that looks like the data entry form and some way to access the report from the data entry form. So add a print button or some such that will open the report. The report needs to look like the form so saving the form as a report is a good jump start but then some comboboxes don't show. Skip to the end for an explanation why. So we have to set the problem report comboboxes manually. One way is to pass parameters to the report when it opens:
Private Sub PrintButton_Click()
'look up DoCmd.OpenReport if you want to do something other than print preview
DoCmd.OpenReport ReportName:="ReportSavedFromForm", OpenArgs:=OriginalformComboBox.Value, View:=acViewPreview
End Sub
Private Sub ReportSavedFromForm_Load()
reportCombobox = Me.OpenArgs
End Sub
As to why the combobox is blank or stuck on the first value, according to the following link reports are not supposed to be used for editing data.
https://social.msdn.microsoft.com/Forums/office/en-US/14c6ec9a-53bd-4546-ba0e-597c41ca7cce/combo-box-drop-down-arrow-invisible-on-reports?forum=accessdev\
So the combobox dropdown arrow will not appear by design. I put this to the test in office 2016 and in the report header and report footer sections the combobox appears blank if the combobox is unbound. If the combobox is bound say to an ID the combobox behaves a little differently. It shows the first record but is just a textbox with no drop down arrow so only the first record ever shows. However in the details section while you still don't have the dropdown arrow the combo box still can be used to replace an id with a more friendly value
I have a "Detail" button in my report that should only show if there is data in the Start and End columns of that row.
Right now, my setup for my Detail text box is:
General > Expression:
=IIF(IsNothing(Fields!StartTime.Value) OR IsNothing(Fields!EndTime.Value), nothing, "Detail")
Action > Go to report > Specify a report > Expression:
=IIF(IsNothing(Parameters!StartDate.Value) OR IsNothing(Parameters!EndDate.Value), Nothing, "Detail Report")
In the report viewer via browser, once you run the report, the cells where Nothing should be applied show a hyphen (-). This hyphen can be clicked on for some reason, despite my "Specify a report" code. However, in the PDF version (or other exported) version of the report, the hyphen is not there. I don't care that the hyphen is there (and I also don't know why it's there), but it can't be clicked on.
If I run the report in Visual Studio I don't see the hyphen. It's when I upload it to our report server and access it from chrome. Once this hyphen is clicked on, it gives an error saying "The 'StartDate' parameter is missing a value."
Am I doing something wrong?
Instead of nothing as the report name, set the report to 0.
So set the goto action as this :
=IIF(IsNothing(Parameters!StartDate.Value) OR IsNothing(Parameters!EndDate.Value), 0, "Asset Drilldown Report")
Ended up being a mistake on my part. In my goto action, I was referencing Parameters!StartDate.Value and Parameters!EndDate.Value, while in my "Detail" text box expression I had it referencing Fields!StartTime.Value and Fields!EndTime.Value. I changed the goto action to the latter, and my problem was fixed.
How do I refer to a report's controls explicitly? Referring implicitly works as expected:
Me.lblTest.Visible = True
However, all of my attempts at referencing the control explicitly meet with various nonsensical runtime errors. Access' favorite:
"The report name 'rptTest' you entered is misspelled (it's not) or refers to a report that isn't open (it is) or doesn't exist (it does)."
I've tried a dozen syntax variations from MSDN and everywhere else I could find, all producing errors:
Reports!rptTest.lblTest.Visible = True
' ^--expected syntax, like Forms!frmName.ctlName.Property
Reports!("rptTest").lblTest.Visible = True
Reports![rptTest].lblTest.Visible = True
Reports("rptTest").Controls("lblTest").Visible = True
etc. etc.
This should be no different from referring to forms' controls, right? There must be a way to refer explicitly to a report's controls.
Check the names of the reports Access thinks are open.
With your report open, go to the Immediate window. Ctrl+g will take you there.
Paste in for each rpt in reports : ? rpt.name : next as one line and press Enter. Access will tell you the names of the open reports as it sees them.
Here is an Immediate window example from my system with one report, rptFoo, open ...
for each rpt in reports : ? rpt.name : next
rptFoo
The problem you're facing is that rptTest is open, but Access disagrees. That discrepancy can be caused at least 3 ways:
rptTest is what you see when the report is open, but that is the report's Caption property instead of its Name
rptTest is a subreport contained in some other open report. The Reports collection, which is where Access looks to find open reports, contains only the "top-level" reports which are open. If you're dealing with a subreport, reference it via its parent report ... Reports!rptParent!SubreportControl!lblTest.Visible where SubreportControl is the name of the subreport control which contains rptTest. Be careful because the name of that subreport control may not be rptTest --- you need the name of the subreport control, not the name of the report it contains.
If rptTest is contained in a subform/subreport control within a form (instead of within a report), the situation is similar to #2, but you must reference it via its parent form ... Forms!YourFormName!SubcontrolName!lblTest.Visible
I have a MS Access 2007 report which is based on a query that has some parameters that can be modified by selecting values in listboxes that are in the header of the report. The flow is as follows:
A user selects parameters in listboxes
A user clicks "generate" button. I have an OnClick event attached to it, which goes through all the listboxes, picks up their selections, puts together an SQL statement and sets it as source for the underlying MS Access query.
The only way I could find to properly refresh the report was to first do Me.Requery and then close and reopen the report. Just Me.Requery was not enough.
After the report is reopened, all the selections in the listboxes are lost. But I have them saved in a variable and I would be able to set them back, but I cannot find a suitable event.
I tried Report Load, Open, Current events - none of them worked. For Current event, I see that the selection gets set but then is deselected immediately. Could anybody suggest me what other event could I try or maybe a slight different approach all together?
Seems to me this one could be easier by giving the user a form with those list box controls, let her make her selections there, and then pass the selection criteria as the WhereCondition parameter to DoCmd.OpenReport.
From that page, the WhereCondition parameter is "A string expression that's a valid SQL WHERE clause without the word WHERE".
I have to build an MS Access form that acts as a registration form for delegates of a conference. I have to print out a receipt acknowledging the delegate's details and payment and other details. I think I have to make a report for this. So I made a rough report containing the required fields and placed a button on the form that prints the report out. When I clicked on it for the first record, it displayed the details faithfully. However, when I navigated to the second record and did the same, it displayed the details of the first record again. What do I do? Also, how can I customise it to mimic a receipt's format? Like so:
"Received with thanks from Mr./Ms. , a sum of Rs." and so on and so forth?
You've probably attached the record source for the Report to the same table/query that you are using for the Form. When you open the Report, you'll actually have receipts for each record in the source table/query.
What I would do in this case, is add a filter to the Report, and filter the records to show the same record as is currently displayed on the form. You can do this when you open the Report. e.g.,
docmd.OpenReport "foo", acViewNormal, , "fooID = " & me.fooID
(note: you may have explicitly turn on filters in the report's parameters)
You can display a customised line like that by building up a string in the default valude for an unbound text box.
="Text" & "foo" & me.value & ""
Or you can set the text box's value on the fly, probably during the OnFormat event.
Or you can do that as part of the query you use to provided data to the report, and use a bound text box.