Syntax error

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
 
R

Rob Parker

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
 
S

SG

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
 
Top