By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,251 Members | 2,764 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,251 IT Pros & Developers. It's quick & easy.

Syntax Error (missing operator) in query expression

P: n/a
Syntax Error (missing operator) in query expression [AnimalID]=BLANK'S
MOLLIE-PRINCE BRUISER-3/14/2004-03

AnimalID is correct. I'm trying to open with a command button or double click
the frmAnimal from a subform that uses the same table, is that my problem?

If I remove the criteria from the expression, it opens the form, but to show
every record.
Michael
Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
lu*************@aol.com (Lumpierbritches) wrote in
news:20***************************@mb-m16.aol.com:
Syntax Error (missing operator) in query expression
[AnimalID]=BLANK'S MOLLIE-PRINCE BRUISER-3/14/2004-03

AnimalID is correct. I'm trying to open with a command button
or double click the frmAnimal from a subform that uses the
same table, is that my problem?

If I remove the criteria from the expression, it opens the
form, but to show every record.
Michael


Iwhat you need to see is
[AnimalID]="BLANK'S MOLLIE-PRINCE BRUISER-3/14/2004-03"

review the location in the button's OnClick event to add extra
quotes. If you can't figure it out, post the relevant sections of
code.

Bob Quintal

Nov 12 '05 #2

P: n/a
Private Sub cmdOpenAnimal_Click()
On Error GoTo Err_cmdOpenAnimal_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmAnimal"

stLinkCriteria = "[AnimalID]=" & "'" & Me![AnimalID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdOpenAnimal_Click:
Exit Sub

Err_cmdOpenAnimal_Click:
MsgBox err.Description
Resume Exit_cmdOpenAnimal_Click

End Sub

Nov 12 '05 #3

P: n/a
On 27 Apr 2004 00:12:01 GMT, Lumpierbritches wrote:
Private Sub cmdOpenAnimal_Click()
On Error GoTo Err_cmdOpenAnimal_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmAnimal"

stLinkCriteria = "[AnimalID]=" & "'" & Me![AnimalID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdOpenAnimal_Click:
Exit Sub

Err_cmdOpenAnimal_Click:
MsgBox err.Description
Resume Exit_cmdOpenAnimal_Click

End Sub


Your problem is you have a single quote in the criteria field....

[AnimalID]=BLANK'S MOLLIE-PRINCE BRUISER-3/14/2004-03

So your Where clause is failing when it hits the ' in Blank's.

Try it this way (instead of using & "'" etc.)

stLinkCriteria = "[AnimalID]=" & chr(34) & Me![AnimalID] & chr(34)

--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.