Yes, the # is used as delimiters around literal dates in the string.
If MCH_CASECODE is a Text field (when you open the field in design view),
use quote marks. Example:
Dim strWhere As String
If Not IsNull(Me.txtCCCODE) Then
strWhere = "MCH_CASECODE = """ & Me!txtCCODE & """"
End If
DoCmd.OpenForm "frmCASES_UNION", acViewNormal, , strWhere
By using a variable for the WhereCondition, you can add the line:
Debug.Print strWhere
and see what it prints to the Debug window if it fails.
For an explanation of the extra quotes, see:
Quotation marks within quotes
at:
http://allenbrowne.com/casu-17.html
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
<ga*****@yahoo.comwrote in message
news:11**********************@22g2000hsm.googlegro ups.com...
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