Syntax Error (Missing Operator)

C

Cathy

In Access 2007, I am trying to open a new form using criteria selected on the
current form. I keep getting the error: Syntax Error (Missing Operator) in
query expression '[Manager] = 'FName LName'[Group Change]=-1'

The cboNameMgr is a drop down box. The Group Change set to 'yes' is what is
needed based on the form they are moving to. Here is my VBA:

' Open the grouping approvals form (frmGroups)
stDocName = "frmGroups"

' Set the manager, and group change flag values that together point to the
subset of records to appear in the form
stLinkCriteria = "[Manager]=" & "'" & Me![cboNameMgr] & "'" & "" &
"[Group Change]=" & "-1" & ""
DoCmd.OpenForm stDocName, , , stLinkCriteria, , acWindowNormal

What am I doing wrong?

Thank you,
 
D

Daryl S

Cathy -

If you need two things to be true ([Manager] = 'FName LName' AND [Group
Change]=-1) Then this is what you need:

stLinkCriteria = "[Manager]=" & "'" & Me![cboNameMgr] & "' AND [Group
Change]= -1"
 
M

Marshall Barton

Cathy said:
In Access 2007, I am trying to open a new form using criteria selected on the
current form. I keep getting the error: Syntax Error (Missing Operator) in
query expression '[Manager] = 'FName LName'[Group Change]=-1'

The cboNameMgr is a drop down box. The Group Change set to 'yes' is what is
needed based on the form they are moving to. Here is my VBA:

' Open the grouping approvals form (frmGroups)
stDocName = "frmGroups"

' Set the manager, and group change flag values that together point to the
subset of records to appear in the form
stLinkCriteria = "[Manager]=" & "'" & Me![cboNameMgr] & "'" & "" &
"[Group Change]=" & "-1" & ""
DoCmd.OpenForm stDocName, , , stLinkCriteria, , acWindowNormal


You need AND between the two conditions and the -1 should
not be quoted:

stLinkCriteria = "Manager='" & Me!cboNameMgr
& "' AND [Group Change] = -1"
 
C

Cathy

Thank you so much Daryl!


Daryl S said:
Cathy -

If you need two things to be true ([Manager] = 'FName LName' AND [Group
Change]=-1) Then this is what you need:

stLinkCriteria = "[Manager]=" & "'" & Me![cboNameMgr] & "' AND [Group
Change]= -1"

--
Daryl S


Cathy said:
In Access 2007, I am trying to open a new form using criteria selected on the
current form. I keep getting the error: Syntax Error (Missing Operator) in
query expression '[Manager] = 'FName LName'[Group Change]=-1'

The cboNameMgr is a drop down box. The Group Change set to 'yes' is what is
needed based on the form they are moving to. Here is my VBA:

' Open the grouping approvals form (frmGroups)
stDocName = "frmGroups"

' Set the manager, and group change flag values that together point to the
subset of records to appear in the form
stLinkCriteria = "[Manager]=" & "'" & Me![cboNameMgr] & "'" & "" &
"[Group Change]=" & "-1" & ""
DoCmd.OpenForm stDocName, , , stLinkCriteria, , acWindowNormal

What am I doing wrong?

Thank you,
 

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