473,394 Members | 1,567 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Docmd.Openform with where condition Syntax

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

Nov 14 '07 #1
3 11771
On Wed, 14 Nov 2007 22:09:46 -0000, ga*****@yahoo.com 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
Nov 14 '07 #2
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
Nov 15 '07 #3
Thanks guys, that worked. I was incorrectly using the # placeholder
for a number datatype
Nov 15 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Aravind | last post by:
Hi folks. I have 2 forms, frmMain and frmHistory. frmHistory has a field called Return. frmMain has a command button called "Due Today" (which will henceforth be called as DT), which opens...
3
by: Lyn | last post by:
Hi, I have a Search input form which collects from the user a person's name. I am using LIKE with a "%" suffix in the SQL so that the user does not have to type in the full name. When they hit...
15
by: Thelma Lubkin | last post by:
formA determines some_where and some_value and issues docmd.close ,Me docmd.openform "formB", , ,some_where, , ,some_value formB receives the correct some_where and some_value After...
8
by: John Welch | last post by:
I have a command button with the following code: DoCmd.OpenForm "frmSearchAssignments", , , "SearchAssignmentID = 1" (SearchAssignmentID is the PK, auto number) When it runs, the form opens but...
2
by: Mike | last post by:
I am trying to open a search results form based on the input from a prompt form. I am using the following code: --- Begin Code --- Private Sub btnSearch_Click() 'Dim Variable and assign data...
2
by: rturpyn | last post by:
I want to simply open a form, I don't want to limit the records returned. I'm using the code.... DoCmd.OpenForm "frm_GSG_Access_Rights", acFormDS, , When I enter something in the where...
1
by: altesse33 | last post by:
I am trying to open the form "frmClients_Main" to the record that is specified by the end user. Here is the code: ---------------------------------------------------------- Public Function...
1
by: silen | last post by:
i am using Access2000. Currently i had a main form call "frmDownload" and sub form "fsubAdmmission". Under the fsubAdmmission, i do have another sub form "fsubHospital". Once i link my application to...
3
by: erict | last post by:
Access 2002-2003 runtime App works fine on single proc machines but we are rolling out a tech refresh and we found this case where the code appears to simply slip through the open form command and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.