A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Where Clause Error In The DoCmd.OpenReport



 
 
Thread Tools Display Modes
  #1  
Old November 13th, 2009, 03:12 AM posted to microsoft.public.access.forms
cheer[_2_]
external usenet poster
 
Posts: 1
Default Where Clause Error In The DoCmd.OpenReport

Error prompt at below code

DoCmd.OpenReport "Report_Machine_Utilisation_Time", acViewPreview, ,
"OpnStartTime between #" & strStartDate & "# And #" & strEndDate & "#"

a) Error message: data type mismatch in criteria expression

b) Both strStartDate and strEndDate is value from TextBox

c) Example of strStartDate or strEndDate value is "11/13/2009 08:00:00"

d) Try before
DoCmd.OpenReport "Report_Machine_Utilisation_Time", acViewPreview, ,
"OpnStartTime between " & cdate(strStartDate) & " And " & cdate(strEndDate) &
""

OR

DoCmd.OpenReport "Report_Machine_Utilisation_Time", acViewPreview, ,
"OpnStartTime between " & Format(strStartDate, "\#mm/dd/yyyy hh:mm:ss\#") & "
And " & Format(strEndDate, "\#mm/dd/yyyy hh:mm:ss\#") & ""

but the same error message prompt

e) OpnStartTime is date field

f) I am using MS Access 2000

g) Tested sample value #11/10/2009# And #11/11/2009# at the query used in the
report. The query works.

Any further advice why the above OpenReport code doesn't work ?

  #2  
Old November 13th, 2009, 04:59 AM posted to microsoft.public.access.forms
Ken Snell
external usenet poster
 
Posts: 177
Default Where Clause Error In The DoCmd.OpenReport

Format the date values as "mm/dd/yyyy" format:

DoCmd.OpenReport "Report_Machine_Utilisation_Time", acViewPreview, ,
"OpnStartTime between #" & Format(strStartDate, "mm\/dd\/yyyy") & "# And #"
& Format(strEndDate, "mm\/dd\/yyyy") & "#"

--

Ken Snell
http://www.accessmvp.com/KDSnell/



"cheer" u56161@uwe wrote in message news:9f089480d41ad@uwe...
Error prompt at below code

DoCmd.OpenReport "Report_Machine_Utilisation_Time", acViewPreview, ,
"OpnStartTime between #" & strStartDate & "# And #" & strEndDate & "#"

a) Error message: data type mismatch in criteria expression

b) Both strStartDate and strEndDate is value from TextBox

c) Example of strStartDate or strEndDate value is "11/13/2009 08:00:00"

d) Try before
DoCmd.OpenReport "Report_Machine_Utilisation_Time", acViewPreview, ,
"OpnStartTime between " & cdate(strStartDate) & " And " &
cdate(strEndDate) &
""

OR

DoCmd.OpenReport "Report_Machine_Utilisation_Time", acViewPreview, ,
"OpnStartTime between " & Format(strStartDate, "\#mm/dd/yyyy hh:mm:ss\#")
& "
And " & Format(strEndDate, "\#mm/dd/yyyy hh:mm:ss\#") & ""

but the same error message prompt

e) OpnStartTime is date field

f) I am using MS Access 2000

g) Tested sample value #11/10/2009# And #11/11/2009# at the query used in
the
report. The query works.

Any further advice why the above OpenReport code doesn't work ?



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:59 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.