Cmd Open Form syntax error

G

Guest

The following error comes up when I click the command button. I am confused
as I created using the wizard

Syntax error (missing operator) in query expression '[Employer]'=' x '

Code is
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Survey responses"

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

Exit_cmdopenform_contact_to_suvey_result:
Exit Sub

Err_cmdopenform_contact_to_suvey_results_Click:
MsgBox Err.Description
Resume Exit_cmdopenform_contact_to_suvey_result

End Sub
 
G

Guest

Hi Nai,

I think your problem is in the stLinkCriteria assignment. There are
definitely extra apostrophies and a missing !

Try this sample below


stLinkCriteria = "[Employer]=" & "'" & Me![Employer] & "'"
 
G

Guest

That has worked. Thank you!

Denny said:
Hi Nai,

I think your problem is in the stLinkCriteria assignment. There are
definitely extra apostrophies and a missing !

Try this sample below


stLinkCriteria = "[Employer]=" & "'" & Me![Employer] & "'"


Nai said:
The following error comes up when I click the command button. I am confused
as I created using the wizard

Syntax error (missing operator) in query expression '[Employer]'=' x '

Code is
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Survey responses"

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

Exit_cmdopenform_contact_to_suvey_result:
Exit Sub

Err_cmdopenform_contact_to_suvey_results_Click:
MsgBox Err.Description
Resume Exit_cmdopenform_contact_to_suvey_result

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