Syntax error (missing operator) in Query Expression bug

C

Carmen

I created a command button that will send users straight to the Check ID#
requested and print that specific Check Request form. It works for records
that start with an alphabet but I get this Syntax error message with the
records that beginning with a numeral.

Here is the code that the computer generated:

Private Sub Command198_Click()
On Error GoTo Err_Command198_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "General Ledger"

stLinkCriteria = "[CheckID]=" & Me![PubID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command198_Click:
Exit Sub

Err_Command198_Click:
MsgBox Err.Description
Resume Exit_Command198_Click

End Sub

What else would I need to add to this code so that my records that beginning
with numerals will also be able to go directly to check ID# specified?
 
D

Duane Hookom

If CheckID is a text field then you must delimit PubID.
stLinkCriteria = "[CheckID]=""" & Me![PubID] & """"
 
C

Carmen

Duane

I've tried it and it still doesn't work. I'm getting an error message: The
OpenForm actions was canceled. I copied and paste your suggestion into my
code and still received the same error message.



Duane Hookom said:
If CheckID is a text field then you must delimit PubID.
stLinkCriteria = "[CheckID]=""" & Me![PubID] & """"

--
Duane Hookom
Microsoft Access MVP


Carmen said:
I created a command button that will send users straight to the Check ID#
requested and print that specific Check Request form. It works for records
that start with an alphabet but I get this Syntax error message with the
records that beginning with a numeral.

Here is the code that the computer generated:

Private Sub Command198_Click()
On Error GoTo Err_Command198_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "General Ledger"

stLinkCriteria = "[CheckID]=" & Me![PubID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command198_Click:
Exit Sub

Err_Command198_Click:
MsgBox Err.Description
Resume Exit_Command198_Click

End Sub

What else would I need to add to this code so that my records that beginning
with numerals will also be able to go directly to check ID# specified?
 
D

Duane Hookom

The code to open the form is probably correct. I expect there is code running
in the new form that is the issue. What happens if you remove any code or
macros from the new/opened form?

--
Duane Hookom
Microsoft Access MVP


Carmen said:
Duane

I've tried it and it still doesn't work. I'm getting an error message: The
OpenForm actions was canceled. I copied and paste your suggestion into my
code and still received the same error message.



Duane Hookom said:
If CheckID is a text field then you must delimit PubID.
stLinkCriteria = "[CheckID]=""" & Me![PubID] & """"

--
Duane Hookom
Microsoft Access MVP


Carmen said:
I created a command button that will send users straight to the Check ID#
requested and print that specific Check Request form. It works for records
that start with an alphabet but I get this Syntax error message with the
records that beginning with a numeral.

Here is the code that the computer generated:

Private Sub Command198_Click()
On Error GoTo Err_Command198_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "General Ledger"

stLinkCriteria = "[CheckID]=" & Me![PubID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command198_Click:
Exit Sub

Err_Command198_Click:
MsgBox Err.Description
Resume Exit_Command198_Click

End Sub

What else would I need to add to this code so that my records that beginning
with numerals will also be able to go directly to check ID# specified?
 
C

Carmen

Duane:

I'm a little new at this so I'm really not understanding what you mean by
remove any code or macros from the new/opened form?

Where would I find that information?

Duane Hookom said:
The code to open the form is probably correct. I expect there is code running
in the new form that is the issue. What happens if you remove any code or
macros from the new/opened form?

--
Duane Hookom
Microsoft Access MVP


Carmen said:
Duane

I've tried it and it still doesn't work. I'm getting an error message: The
OpenForm actions was canceled. I copied and paste your suggestion into my
code and still received the same error message.



Duane Hookom said:
If CheckID is a text field then you must delimit PubID.
stLinkCriteria = "[CheckID]=""" & Me![PubID] & """"

--
Duane Hookom
Microsoft Access MVP


:

I created a command button that will send users straight to the Check ID#
requested and print that specific Check Request form. It works for records
that start with an alphabet but I get this Syntax error message with the
records that beginning with a numeral.

Here is the code that the computer generated:

Private Sub Command198_Click()
On Error GoTo Err_Command198_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "General Ledger"

stLinkCriteria = "[CheckID]=" & Me![PubID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command198_Click:
Exit Sub

Err_Command198_Click:
MsgBox Err.Description
Resume Exit_Command198_Click

End Sub

What else would I need to add to this code so that my records that beginning
with numerals will also be able to go directly to check ID# specified?
 
D

Duane Hookom

I assume you have correctly modified your code to handle [CheckID] as a text
field. You have never confirmed whether CheckID is truly text.

What is your exact code?
Do you have any code in the On Open or On Current events of the form you are
opening?

--
Duane Hookom
Microsoft Access MVP


Carmen said:
Duane:

I'm a little new at this so I'm really not understanding what you mean by
remove any code or macros from the new/opened form?

Where would I find that information?

Duane Hookom said:
The code to open the form is probably correct. I expect there is code running
in the new form that is the issue. What happens if you remove any code or
macros from the new/opened form?

--
Duane Hookom
Microsoft Access MVP


Carmen said:
Duane

I've tried it and it still doesn't work. I'm getting an error message: The
OpenForm actions was canceled. I copied and paste your suggestion into my
code and still received the same error message.



:

If CheckID is a text field then you must delimit PubID.
stLinkCriteria = "[CheckID]=""" & Me![PubID] & """"

--
Duane Hookom
Microsoft Access MVP


:

I created a command button that will send users straight to the Check ID#
requested and print that specific Check Request form. It works for records
that start with an alphabet but I get this Syntax error message with the
records that beginning with a numeral.

Here is the code that the computer generated:

Private Sub Command198_Click()
On Error GoTo Err_Command198_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "General Ledger"

stLinkCriteria = "[CheckID]=" & Me![PubID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command198_Click:
Exit Sub

Err_Command198_Click:
MsgBox Err.Description
Resume Exit_Command198_Click

End Sub

What else would I need to add to this code so that my records that beginning
with numerals will also be able to go directly to check ID# specified?
 

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