OpenForm "Where condition" contains hyphen

5hadow

Member
Local time
Today, 12:00
Joined
Apr 26, 2021
Messages
89
I'm having issues figuring out how to fix this bit of code:
Private Sub fldSerial_Click() DoCmd.OpenForm "frmDocRevDetail", , , "[fldSerial]=" & MaxOffldSerial End Sub

MaxOffldSerial contains a hyphen. It looks something like this: DR-22-001.
When I click on the field, it opens the following box:
1643646283778.png


How do I write the code so that it knows what to open. It seams it stops at hyphen because it's a special character?
 
If it has a hyphen then it is text so you need to surround with single quotes. At the moment it is treating you code as a calculation
 
Never mind, figured it out. It's supposed to be:

Private Sub fldSerial_Click() DoCmd.OpenForm "frmDocRevDetail", , , "[fldSerial]='" & (Me.MaxOffldSerial) & "'" End Sub
 

Users who are viewing this thread

Back
Top Bottom