Re: Docmd.Openform with where condition Syntax



On Wed, 14 Nov 2007 22:09:46 -0000, gavm360@xxxxxxxxx wrote:

Hello, im trying to open a form from an dialog box form:

the button on the dialog box has this on the onclick event:

DoCmd.OpenForm "frmCASES_UNION", acViewNormal, , "MCH_CASECODE = #" &
Me!txtCCODE & "#"

the form I'm trying to open is "frmcases_union"
and im trying to filter it by the "MCH_CASECODE" which i type into
txtCCODE.

When i click i get:
Run-time error 3705
Syntax error in date in query expression MCH_CASECODE = #1360#

is it because im using # signs which makes it think its a date?? what
should i use as placeholders?

Thanks, Gavin

Why are you using
"MCH_CASECODE = #" Me!txtCCODE & "#" ?
The # is a date delimiter symbol. By your surrounding your variable
with #, Access is expecting a date value, but MCH_CASECODE is not a
date field.

What is the datatype of the "MCH_CASECODE" field?

If MCH_CASECODE is Text datatype, then use:
"MCH_CASECODE ='" & Me!txtCCODE & "'"

The above will return the 1360 value as text:
"MCH_CASECODE = '1360'"

If it is a Number datatype then use:
"MCH_CASECODE =" & Me!txtCCODE

The above will return the 1360 value as a Number
"MCH_CASECODE = 1360"
I would suspect that you need the Number datatype syntax.



--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
.