OpenForm "Where condition" contains hyphen (1 Viewer)

5hadow

Member
Local time
Today, 17:50
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?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 22:50
Joined
Feb 19, 2013
Messages
16,610
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
 

5hadow

Member
Local time
Today, 17:50
Joined
Apr 26, 2021
Messages
89
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

Top Bottom