syntax error missing operator in command button

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
 
G

Guest

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] & "'"
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top