Inputbox

Arcadia

Registered User.
Local time
Today, 06:00
Joined
Jan 25, 2013
Messages
66
I have a question and really hope someone can help me out here :rolleyes:

In access I have made a report with fields I have also made a Button to send a mail to users but my goal is now that if users click the button they can insert the "Start date" and the "End date" in a inputbox the "Start date" and "End date" are from a query called Calender_query. I want to do this so only the info of the chosen dates will be inserted in the mail body.

I think i have a part of the code but i don't know what to put in the middle..

Set db = CurrentDb
Set qdf = db.QueryDefs("Calender_query")


Set rst = qdf.OpenRecordset()
 
Can someone atleast tell me or it is possible?
 
Show the SQL of the Calender Query.
 
Why not add two fields on your report?
One for the start date, the other for the end date. Make them a list box so you can select value form your query.
 
You're better off using a form for collecting the dates.
 
Show the SQL of the Calender Query.

SELECT TrainingCalender.Title, TrainingCalender.Location, TrainingCalender.[Start Time], TrainingCalender.[End Time], TrainingCalender.Description, TrainingCalender.Duration
FROM TrainingCalender, Selection
WHERE (((TrainingCalender.[Start Time])>=[start]) AND ((TrainingCalender.[End Time])<=[end]));
 
Here !
Code:
Dim startDate As Date, endDate As Date

startDate = CDate(InputBox("Enter Start Date : ", "Required", Date())
endDate = CDate(InputBox("Enter End Date : ", "Required", Date())

Set db = CurrentDb

Set rst = db.OpenRecordset("SELECT TrainingCalender.Title, TrainingCalender.Location, TrainingCalender.[Start Time], " & _
                           "TrainingCalender.[End Time], TrainingCalender.Description, TrainingCalender.Duration 
                           "FROM TrainingCalender " & _
                           "WHERE (TrainingCalender.[Start Time] >= " & Format(startDate, "\#mm\/dd\/yyyy") & _
                           " AND TrainingCalender.[End Time] <= " & Format(endDate, "\#mm\/dd\/yyyy") & ");")
I would go with the Form controls to get the date range as vbaInet suggested.
 

Users who are viewing this thread

Back
Top Bottom