I am using a form to select a filter value to open a report. The report data source is a query listing rooms and their uses (office, storage, etc.). The usage table key is “RmUseID” and the literal is “RmUse” and is part of the query that builds the report.
The form uses a combo box based on a query using “RmUseID” and “RmUse” – the bound column is “RmUseID”.
The form button click event has the following code:
Private Sub RmUseSelect_Click()
If IsNull(RmUseID) Then
MsgBox "Please Select a Room Use"
Else
Dim filter
filter = "[RmUseID] ='" & RmUseID & "'"
DoCmd.OpenReport "mhc filtrmr", acViewPreview, filter
End If
End Sub
The query in the report has in the ‘criteria’ row under the “RmUseID” - [forms]![mainswitchbdf]![rmuseid].
When I click the form button, I get a ‘parameter needed’ pop-up – if I put a RmUseID in, the report opens showing the filtered data. If I scroll over ‘filter’ in the docmd in the form when debugging, I see the correct RmUseID is there. But it is not being passed to the report or is not being recognized by the report.
And if I open up the report alone, I get the parameter popup – entering a valid RmUseID gives me a correct filtered report. I’ve checked field names, spelling, syntax – I’m at a loss.