473,320 Members | 1,900 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,320 software developers and data experts.

DoCmd.OpenReport with date criteria generating Runtime error

Hi, I have a table with a DateTime field [Entry Date] and a form where a user enters a date and hits a "submit" button to open a report that should only display entries whose dates match the user entry. When I run this line of code to open the report:

DoCmd.OpenReport "All Employee Daily Report 2", acViewReport, , "[Entry Date] = " & Format(Me.txtDate, "\#mm\/dd\/yyyy\#")

I get this error:
Run-time error '102':
Incorrect syntax near '#'

Can someone help me out? I was under the impression that dates have to be enclosed in '#' so i'm not sure what's the problem.
Mar 17 '15 #1
2 1648
Brilstern
208 100+
I believe you would only use # when you are enclosing an actual date. Try this.

Expand|Select|Wrap|Line Numbers
  1. Dim strValue as String
  2.  
  3. strValue = "#" & Me.txtDate & "#"
  4. DoCmd.OpenReport "All Employee Daily Report 2", acViewReport, , "[Entry Date] = " & Format(strValue, "mm/dd/yyyy")
This is just a shot in the dark, haven't tested it yet.
Mar 17 '15 #2
MikeTheBike
639 Expert 512MB
Hi

I always use
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "All Employee Daily Report 2", acViewReport, , "[Entry Date] = #" & Format(Me.txtDate, "mm/dd/yyyy") & "#"
  2.  
??

MTB
Mar 19 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Andrew | last post by:
Hi All: I am using Access2000 and I find that the command to open an Access report in preview mode is very slow: DoCmd.OpenReport rptABC, acViewPreview, "", "" The scenario is this: - The...
1
by: JohnM | last post by:
I don't seem to be able to get opening a report and sortin the rcords right. I an open the report, limited to a range of my choosing. So, for example the code below opens my report and limits it...
2
by: enough2Bdangerous | last post by:
Access database (file format 2002-2003) generates reports with docmd.openreport but returns 3011 runtime error related to the printer. Switching Windows default printer is a work around but need to...
3
by: enough2Bdangerous | last post by:
access runtime error 3011 on docmd.openreport -------------------------------------------------------------------------------- Access database (file format 2002-2003) generates reports with...
3
by: russellhq | last post by:
Hi, i am trying to open a report based on values picked in a form but get stuck with one of the values. I have a feeling it has to do with the yes/no datatype but am not sure since I am quite new...
5
by: lvjan777 | last post by:
Access 2003 Windows XP Professional I'm trying to open a report that displays all the records that are active during the user selected start and stop dates. I’m having trouble with the syntax...
3
by: Jim Armstrong | last post by:
Hello all - This is driving me crazy. I have a table called tblClients - very simple, has the following fields: taxID (PK) ClientName SalesName The main form of my application allows a...
4
by: gazza10001 | last post by:
Hi i hope you can help my company uses access and has modified for its needs usually what happens is you serach for the invoice by its number and then it brings all the information up such as...
1
by: resqtech | last post by:
I am having an issue with an Access Database that worked at one time and after a Windows Update that screwed up the profile it stopped working. The following is what VB is stating causes the error. ...
2
by: Russell613 | last post by:
I have a shared database that prints out pull lists for inventory. The user puts in there information in a form and clicks a button at the bottom for the printing. The printing works on all...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.