Error message: Syntax error(missing operator)in query expression

G

Guest

I have 2 forms a product change form and an ECN form, the ECN form is opened
by a comand button on the product change form using the code below. What I
am trying to do is this: bring the Product change number from that form into
the ECN form when the ECN form is opened and then also bring in the
Description, reason, and Summary into the same ECN form when opened. These
are all listed on the product change form. If I only try to to the
ProductChangeNo it will work fine, but when I try to do the others I get the
message listed below the code.

Code being used:

Private Sub OpnECNFormCMD_Click()
On Error GoTo Err_OpnECNFormCMD_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "FRM_ECN_Issued"
stLinkCriteria = "[ChangeDoc]=" & Me![ProductChangeNo]
stLinkCriteria = stLinkCriteria & "[Description]=" & Me![DescribeRequest]
stLinkCriteria = stLinkCriteria & "[Reason]=" & Me![ReasonforRequest]
stLinkCriteria = stLinkCriteria & "[Summary]=" & Me![SummaryofChange]
DoCmd.OpenForm stDocName, , , stLinkCriteria


Exit_OpnECNFormCMD_Click:
Exit Sub

Err_OpnECNFormCMD_Click:
MsgBox Err.Description
Resume Exit_OpnECNFormCMD_Click

End Sub

Error Message receiving:

Syntax error (missing operator) in query expressing
'[ChangeDoc]"=1[Description]=Add (2) 05040006 and (2) 05020017 to kit
11190011[Reason]=To provide enough screws for all inslationss of overhead
hose retrofits[Summary]=Revised BOM'

The information being shown for each of the fields is correct but I can't
tell what operator is missing or where. I'm somewhat new to writing code to
do things but I'm trying, please let me know what I've missed.
 
G

Guest

Syntax error (missing operator) in query expressing

You've given it a "run-on sentence." ;-)

Spaces are needed between the criteria and string values need to be
delineated, too. When there are more than one criteria to be assigned, the
Keyword AND must be placed between each separate criteria, so that all of
these conditions must apply. Try (watch out for word wrap):

stDocName = "FRM_ECN_Issued"
stLinkCriteria = "[ChangeDoc]=" & Me![ProductChangeNo] & _
" AND " & _
stLinkCriteria = stLinkCriteria & "[Description]='" & _
Me![DescribeRequest] & "' AND " & _
stLinkCriteria = stLinkCriteria & "[Reason]='" & _
Me![ReasonforRequest] & "' AND " & _
stLinkCriteria = stLinkCriteria & "[Summary]='" & _
Me![SummaryofChange] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.


Leslie said:
I have 2 forms a product change form and an ECN form, the ECN form is opened
by a comand button on the product change form using the code below. What I
am trying to do is this: bring the Product change number from that form into
the ECN form when the ECN form is opened and then also bring in the
Description, reason, and Summary into the same ECN form when opened. These
are all listed on the product change form. If I only try to to the
ProductChangeNo it will work fine, but when I try to do the others I get the
message listed below the code.

Code being used:

Private Sub OpnECNFormCMD_Click()
On Error GoTo Err_OpnECNFormCMD_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "FRM_ECN_Issued"
stLinkCriteria = "[ChangeDoc]=" & Me![ProductChangeNo]
stLinkCriteria = stLinkCriteria & "[Description]=" & Me![DescribeRequest]
stLinkCriteria = stLinkCriteria & "[Reason]=" & Me![ReasonforRequest]
stLinkCriteria = stLinkCriteria & "[Summary]=" & Me![SummaryofChange]
DoCmd.OpenForm stDocName, , , stLinkCriteria


Exit_OpnECNFormCMD_Click:
Exit Sub

Err_OpnECNFormCMD_Click:
MsgBox Err.Description
Resume Exit_OpnECNFormCMD_Click

End Sub

Error Message receiving:

Syntax error (missing operator) in query expressing
'[ChangeDoc]"=1[Description]=Add (2) 05040006 and (2) 05020017 to kit
11190011[Reason]=To provide enough screws for all inslationss of overhead
hose retrofits[Summary]=Revised BOM'

The information being shown for each of the fields is correct but I can't
tell what operator is missing or where. I'm somewhat new to writing code to
do things but I'm trying, please let me know what I've missed.
 
G

Guest

When I put in that code I get a completely blank form and the error message
type mismatch and all datatypes are the same, i.e. productcode is autonumber,
and the rest are memo fields.

'69 Camaro said:
Syntax error (missing operator) in query expressing

You've given it a "run-on sentence." ;-)

Spaces are needed between the criteria and string values need to be
delineated, too. When there are more than one criteria to be assigned, the
Keyword AND must be placed between each separate criteria, so that all of
these conditions must apply. Try (watch out for word wrap):

stDocName = "FRM_ECN_Issued"
stLinkCriteria = "[ChangeDoc]=" & Me![ProductChangeNo] & _
" AND " & _
stLinkCriteria = stLinkCriteria & "[Description]='" & _
Me![DescribeRequest] & "' AND " & _
stLinkCriteria = stLinkCriteria & "[Reason]='" & _
Me![ReasonforRequest] & "' AND " & _
stLinkCriteria = stLinkCriteria & "[Summary]='" & _
Me![SummaryofChange] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.


Leslie said:
I have 2 forms a product change form and an ECN form, the ECN form is opened
by a comand button on the product change form using the code below. What I
am trying to do is this: bring the Product change number from that form into
the ECN form when the ECN form is opened and then also bring in the
Description, reason, and Summary into the same ECN form when opened. These
are all listed on the product change form. If I only try to to the
ProductChangeNo it will work fine, but when I try to do the others I get the
message listed below the code.

Code being used:

Private Sub OpnECNFormCMD_Click()
On Error GoTo Err_OpnECNFormCMD_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "FRM_ECN_Issued"
stLinkCriteria = "[ChangeDoc]=" & Me![ProductChangeNo]
stLinkCriteria = stLinkCriteria & "[Description]=" & Me![DescribeRequest]
stLinkCriteria = stLinkCriteria & "[Reason]=" & Me![ReasonforRequest]
stLinkCriteria = stLinkCriteria & "[Summary]=" & Me![SummaryofChange]
DoCmd.OpenForm stDocName, , , stLinkCriteria


Exit_OpnECNFormCMD_Click:
Exit Sub

Err_OpnECNFormCMD_Click:
MsgBox Err.Description
Resume Exit_OpnECNFormCMD_Click

End Sub

Error Message receiving:

Syntax error (missing operator) in query expressing
'[ChangeDoc]"=1[Description]=Add (2) 05040006 and (2) 05020017 to kit
11190011[Reason]=To provide enough screws for all inslationss of overhead
hose retrofits[Summary]=Revised BOM'

The information being shown for each of the fields is correct but I can't
tell what operator is missing or where. I'm somewhat new to writing code to
do things but I'm trying, please let me know what I've missed.
 

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