syntax error missing operator in command button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I get the following message when I click on my command button. Syntax error
(missing operator) in query expression '[POR ID]='. I have tried changing
the code as listed in other help responses, but then I get the message that
the open command has been cancelled. The code the wizard set up is as
follows.

Private Sub Item_Entry_Click()
On Error GoTo Err_Item_Entry_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Item Entry Form"

stLinkCriteria = "[POR ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Item_Entry_Click:
Exit Sub

Err_Item_Entry_Click:
MsgBox Err.Description
Resume Exit_Item_Entry_Click

End Sub
 
If [POR ID] is a numeric field, the code should work. If it is not numeric,
the syntax should be:
stLinkCriteria = "[POR ID]= '" & Me![ID] & "'"
 
It is a numeric field and it worked yesterday, but not today. I even tried
to delete the command button and put it in again. Any other suggestions?

Klatuu said:
If [POR ID] is a numeric field, the code should work. If it is not numeric,
the syntax should be:
stLinkCriteria = "[POR ID]= '" & Me![ID] & "'"
--
Dave Hargis, Microsoft Access MVP


mh7800 said:
I get the following message when I click on my command button. Syntax error
(missing operator) in query expression '[POR ID]='. I have tried changing
the code as listed in other help responses, but then I get the message that
the open command has been cancelled. The code the wizard set up is as
follows.

Private Sub Item_Entry_Click()
On Error GoTo Err_Item_Entry_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Item Entry Form"

stLinkCriteria = "[POR ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Item_Entry_Click:
Exit Sub

Err_Item_Entry_Click:
MsgBox Err.Description
Resume Exit_Item_Entry_Click

End Sub
 
Back
Top