generating a report

rikklaney1

Registered User.
Local time
Yesterday, 19:32
Joined
Nov 20, 2014
Messages
157
I have a question about generating a report. In the criteria of the query my report is based on I have this...

[forms]![subfrmCustom_report]![serial]

which works great to look up the record for that serial number. Now is it possible to modify this so that if I leave that field on the form blank it will return all the records? I tried this...

iif(not isnull([forms]![subfrmcustom_report]![serial],[forms]![subfrmcustom_report]![serial],)

but no luck. Where am I going wrong?
 
For the case where everything is to be shown or where IsNull([forms]![subfrmcustom_report]![serial]) is true iif needs to return something that will display everything. One thing that will do this is the name of the table field. Let's say for example the name of the table field is SerialNumber, then your iif would be like:

Code:
IIf(IsNull([Forms]![subfrmcustom_report]![serial]),[SerialNumber], [Forms]![subfrmcustom_report]![serial])
 
Awesome, that did it. Thanks
 
another related question it would appear that I can set columns in a query to show/not show in a similar fashion as on a form with something like this

If Forms!subfrmCustom_report!Check19.Value = True Then Query!customrptqry!column17.ColumnHidden = True


but it doesn't work. How do I know the names of my columns in a query? It doesn't seem to be numerical like a listbox but it also doesn't seem to be the "field" title in the query itself.
 
supposed that your query is already showing, and you want to hide some columns through the use of VBA:

If Forms!subfrmCustom_report!Check19.Value = True Then
DOCMD.SelectObject acQuery, "NameOfYourQuery", False
SCREEN.ActiveDatasheet!ColumnToHide.ColumnHidden = True
End If
 
New Bitmap Image (3).jpg



Better clarification on what I mean. How would I call this value in vba when opening the query?
 
How would I call this value in vba when opening the query?
is CustomRPTQry be used in a report, or just being displayed as datasheet?
if datasheet:

DoCmd.docmd.OpenQuery "CustomRPTQry",acViewNormal
If Forms!subfrmCustom_report!Check19.Value = True Then
DOCMD.SelectObject acQuery, "CustomRPTQry", False
SCREEN.ActiveDatasheet!ColumnToHide.ColumnHidden = True
End If
 
use your report's Load event, to set its control's width to 0:

private sub Report_Load()
If Forms!subfrmCustom_report!Check19.Value = True Then
Me.yourControlName.Width = 0
End If
 
I thought maybe I could eliminate it from the query altogether on demand but I did figure out how to just hide it on the report. It leaves some blank areas but it works.
 
do remove some blank areas, on your report design view select all controls and on the menu Arrange->Table, select Tabular or stacked.
then when you set the column of one of your control to zero, the controls to the right will adjust to the left and fill those blank areas.
 
Sweet. What about subreports? Can I filter them the same as a subform? I tried this...

Me.boomsub.Report.Filter = "[Station] like 'b*'"
Me.boomsub.Report.FilterOn = True

but no luck.
 
Nevermind, looks like I can do the filter idea through the grouping options on the report.
 

Users who are viewing this thread

Back
Top Bottom