Syntax error

  • Thread starter Thread starter SG
  • Start date Start date
S

SG

Quick question, I have the following behind a list box on a click event but
I am getting a syntax error in query expression 'PRODUCTGROUP ='Ladies
Watches'

Where am I going wrong? the PRODUCTGROUP field is a text field and not a
number field.

Any help would be gratefuly recieved




DoCmd.OpenForm FormName:="frmADDPRODUCTGROUP", _
WhereCondition:="PRODUCTGROUP = '" & Me.List6


Thank you

S
 
You are missing the closing quote delimiter for the text string in your
WHERE clause. Try:

DoCmd.OpenForm FormName:="frmADDPRODUCTGROUP", _
WhereCondition:="PRODUCTGROUP = '" & Me.List6 & "'"
(that's double-quote - single-quote - double-quote).

That solution will break if the string in your listbox contains an embedded
single-quote character. If that's possible, replace both single-quote
characters (the one at the end of PRODUCTGROUP = ' and the one in the
closing delimiter) with a pair of double-quote characters.

HTH,

Rob
 
Thanks for your help Rob worked a treat!


Rob Parker said:
You are missing the closing quote delimiter for the text string in your
WHERE clause. Try:

DoCmd.OpenForm FormName:="frmADDPRODUCTGROUP", _
WhereCondition:="PRODUCTGROUP = '" & Me.List6 & "'"
(that's double-quote - single-quote - double-quote).

That solution will break if the string in your listbox contains an
embedded single-quote character. If that's possible, replace both
single-quote characters (the one at the end of PRODUCTGROUP = ' and the
one in the closing delimiter) with a pair of double-quote characters.

HTH,

Rob
 

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

Similar Threads

Syntax Error (Missing Operator) 3
Funky Syntax Error 19
Syntax for Autonumber + Where Condition 3
Syntax error (missing operator) 1
Syntax Error 3
SQL Syntax Error 6
Syntax error 18
DLookup Syntax Error 3

Back
Top