Open Report based on Text Box

adrienne_r30

Registered User.
Local time
Today, 01:21
Joined
Jan 20, 2015
Messages
48
Hi All,

I am trying to open a report based on a calculated text box. The Calculated text box is,

cmdLowFunds: IIf([sqlAvailable]<10000,1,0)

which works just fine.

then I have a button on a form that opens the report, the code for that is;

Private Sub CmdLowFunds_Click()
On Error GoTo Err_CmdLowFunds_Click
Dim stDocName As String
stDocName = "rpt_Grant_Project_Funding"
DoCmd.OpenReport stDocName, acPreview, , "[Reports]![rpt_Grant_Project_Funding]![cmdLowFunds]= 1"

Exit_CmdLowFunds_Click:
Exit Sub
Err_CmdLowFunds_Click:
Resume Exit_CmdLowFunds_Click
End Sub

when I remove the Where clause, it opens the report just fine. But when I insert the where clause, no data shows up. I have records that show a "1", so I know there is data. I have also spent a lot of time with different renditions of the 1. Such as;

= '1'"
= ""1""
= '" & 1 & "'"

I just cant seem to get it to work.

I was thinking maybe it's how I have my calculated field, should it be:

cmdLowFunds: IIf([sqlAvailable]<10000,'1','0')
or
cmdLowFunds: IIf([sqlAvailable]<10000,"1","0")

any help would be appreciated.

Thanks
 
Don't try an use the report you are opening as part of the Where clause - it won't work as it doesn't exist at the point of opening the report...

You should only need "[cmdLowFunds]= 1"
 
Worked great! Thanks
 

Users who are viewing this thread

Back
Top Bottom