Natchiket:
The Function you recommended work as I needed as well as adding the Form to collect dates. In order to run the report I had to add a DoCmd.Open report in the click event of the date collection Form.
Thanks
Main Topics
Browse All TopicsUsing a MS Access Query I need to gather a start date and end date from the user(see code sample). In my SQL I need to append a static start time and end time. I don't want to gather the timestamp from the user because the start and end timestamp is always repeated. Start time is "12:00:00 AM" and End time is "11:59:59 PM". I need the start and end times to be appended to the user date input "mm/dd/yyy". I have a linked oracle table with a date type field that contains both the date and timestamp (mm/dd/yy hh:mm:ss AM/PM).
How do I append the time to the user input in my SQL and have the query compare "mm/dd/yyyy hh:mm:ss AM/PM" to the values in my linked oracle table?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: NatchiketPosted on 2009-03-24 at 04:04:31ID: 23966565
hi brettleebrown y") & " 12:00:00 AM# AND " ) & "11:59:59 PM#"
Date),Cdat e(Me.txtEn dDate))
The way i would suggest is by using VBA to compile the query string for you, as you won't be able to build the criteria strings directly in the SQL (afaik)
e.g.
Function BuildSQL(datStart as Date,datEnd as Date) as string
Dim strSQL as String
strSQL = "SELECT table.datetimestamp FROM table WHERE table.datetimestamp BETWEEN #" &
strSQL = strSQL & Format(datStart,"dd/mm/yyy
strSQL = strSQL & Format(datEnd,"dd/mm/yyyy"
BuildSQL=strSQL
End Function
you could then have a user form that collects the starts and end dates and feeds them to the function and then sets the SQL of the query when the user clicks a button
e.g. suppose you have two textboxes on the form txtStartDate, txtEndDate and a command button cmdButt
sub cmdButt_Click()
Dim db as Database
Dim qdf as QueryDef
Set db = CurrentDb()
Set qdf = db.querydefs("My oracle query")
qdf.SQL = BuildSQL(Cdate(Me.txtStart
End Sub