Openform - Date range

Oscar_W

Registered User.
Local time
Today, 10:11
Joined
Mar 9, 2006
Messages
42
I have spent hours trying to sort this via searching here and elsewhere. A button on a diary form sends an email containing the day's events. I have been asked to send the current day and the next day. This has me stumped!
Code:
Form_OpenDate = Format(Me.Text62, "MM/DD/YYYY")  ' Gets the date being viewed & converts format to US

strDocName = "Frm_NBCDO_Handover"  ' Form to be Emailed
SecondDay = DateAdd("d", 1, [Form_OpenDate]) ' Finds the next day
NextDay = Format(SecondDay, "MM/DD/YYYY")  ' Converts date format to US

'Single day code works fine
'wherestring = "StartDate =  #" & Form_OpenDate & "# "

'New code
'wherestring = "StartDate =  #" & Form_OpenDate & "#  or #" & NextDay & "#" ' Works but opens with the entire diary 
'wherestring = "StartDate =  #" & Form_OpenDate & "# and #" & NextDay & "#" ' Works but still only opens with the current day

DoCmd.OpenForm strDocName, acNormal, , wherestring

The new code is currently commented out. Can someone please help me with the correct format for the Wherestring. :confused:
Thanks,
Oscar
 
Not 100% sure, but try this:

wherestring = (("StartDate = #" & form_opendate & "#")) OR (("startdate= #" & nextday & "#"))
 
Afraid not. The code jumps straight to the error section and doesn't even appear to make any sense of the string.
 
Got it !

The code below fixed it
Code:
wherestring = "StartDate between #" & Form_OpenDate & "# and #" & NextDay & "#"

Hope this helps someone else.
 

Users who are viewing this thread

Back
Top Bottom