Solved Open Report with where condition (1 Viewer)

wilder20

New member
Local time
Today, 06:01
Joined
Sep 14, 2019
Messages
10
I am using Access 2016, I am trying to open a report with a where condition, on a form I have a unbound combo box listing names (Cbo_Fltr_AADCtrCd) (saved as text) and on the report the field to be filtered is (AADInstalledBy) (saved as text) the report will open without the were clause, but when the combobox is selected the report is blank. What Im i doing wrong, listed below is the code that I tried.

If IsNull(Me.Cbo_Fltr_RigNm) Then
DoCmd.OpenReport "Rpt_AAD", acViewPreview
Else
DoCmd.OpenReport "Rpt_AAD", acViewPreview, , "[AADInstallBy]" = " & Forms![Reports_Frm]![Cbo_Fltr_RigNm] & """ 'Report is blank
'DoCmd.OpenReport "Rpt_AAD", acViewPreview, , [AADInstallBy] = "' Forms![Reports_Frm]![Cbo_Fltr_RigNm] " '" 'Does nothing
'DoCmd.OpenReport "Rpt_AAD", acViewPreview, , [AADInstallBy] = " Forms![Reports_Frm]![Cbo_Fltr_RigNm] " 'Does nothing
'DoCmd.OpenReport "Rpt_AAD", acViewPreview, , [AADInstallBy] = "'" & Forms![Reports_Frm]![Cbo_Fltr_RigNm] & "'""" 'Report is blank
'DoCmd.OpenReport "Rpt_AAD", acViewPreview, , [AADInstallBy] = Forms![Reports_Frm]![Cbo_Fltr_RigNm] 'Does Nothing
'DoCmd.OpenReport "Rpt_AAD", acViewPreview, , [AADInstallBy] = " & Forms![Reports_Frm]![Cbo_Fltr_RigNm] & " 'Does nothing
'DoCmd.OpenReport "Rpt_AAD", acViewPreview, , [AADInstallBy] = Forms![Reports_Frm]![Cbo_Fltr_RigNm] 'Does nothing

End If
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:01
Joined
Oct 29, 2018
Messages
21,358
Hi. Try it this way:
Code:
DoCmd.OpenReport "Rpt_AAD", acViewPreview, , "[AADInstallBy] = '" & Forms![Reports_Frm]![Cbo_Fltr_RigNm] & "'"
Hope that helps...
 

wilder20

New member
Local time
Today, 06:01
Joined
Sep 14, 2019
Messages
10
Thank you, works beautifully. I think I need to learn exactly where to put this apostrophes and quotes.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:01
Joined
Oct 29, 2018
Messages
21,358
Thank you, works beautifully. I think I need to learn exactly where to put this apostrophes and quotes.
Hope this helps...

 

Users who are viewing this thread

Top Bottom