Basic VBA to open report based on field

miacino

Registered User.
Local time
Today, 09:34
Joined
Jun 5, 2007
Messages
106
I thought this would be a very basic VBA code. I'm trying to open a report, using a command button, based on a mutual field in the report and on the open form [positionID].
While it does open the report, it is not limiting the report to that specific [positionID].

---------------------
Private Sub Command553_Click()

If Me.PositionStatus.Value = "Per Diem" Then
DoCmd.OpenReport "Offer Packet_Cover PerDiem", acViewPreview, , [PositionID] = Me.[PositionID]
End If

End Sub
-----------------------------

:banghead:
 
Hi. The Where Condition argument of the OpenReport method expects a String value. Try enclosing it with quotes. For example:
Code:
DoCmd.OpenReport "Offer Packet_Cover PerDiem", acViewPreview, , "[PositionID] = " & Me.[PositionID]
 
Yes, that's it! Thank you!
(I should have known that! ....I just got over 3 days in bed with the flu. I'm blaming my lapse on that!):D
 
Hi. No worries. We all make mistakes. Cheers!
 

Users who are viewing this thread

Back
Top Bottom