Syntax Error (Missing Operator)

  • Thread starter Thread starter Cathy
  • Start date Start date
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,
 
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"
 
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"
 
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,
 
Back
Top