Date range

G

Galin

Hi guys,

I have a form that runs totals when I specify Date Range
(...From ...To). How do I code my form when user doesn't
enter any dates (just leave the boxes blank)my form runs
all totals for every single day?

Or when a user enters only starting date, how do I code
my form to display the results after the specified date
unitl last day?

Thank you in advance
Galin
 
B

Byron

Galin,

You can place code in the OnExit event of each of your
date boxes that will check to see if the user has
provided a date.

Your code would be:

If IsNull(Me.NameOfYourCtrl) then
'here you can set a value or whatever
'if you want to set today's date you could:
me.NameOfYourCtrl = Date
EndIf
 
A

Alan Fisher

-----Original Message-----
Hi guys,

I have a form that runs totals when I specify Date Range
(...From ...To). How do I code my form when user doesn't
enter any dates (just leave the boxes blank)my form runs
all totals for every single day?

Or when a user enters only starting date, how do I code
my form to display the results after the specified date
unitl last day?

Thank you in advance
Galin


.I do the same thing and here is how I handle it. I have
a button that once the date ranges are filled in the user
clicks to generate the report. I put the following code at
the begginging of the On Click event of the button:

If (IsNull(Me.txtBeginingDate) Or IsNull
(Me.txtEndingDate)) Then
MsgBox "Both Begining and Ending Date must be filled in"
Exit Sub
End IfYhat way the report won't run until the user puts in both
dates.

I also check the value of the text boxes with the After
Update event to make sure the ending date is not before
the beginning date like this:

for the beginning date text box
If Me.txtBeginingDate > Me.txtEndingDate Then
MsgBox "The Begining date must be before the Ending date"
Me.txtBeginingDate = Null
End If

This code could also be in the On Click event of the
button as long as you put the Exit Sub line after the
Msgbox.
 
G

galin

Thank you guys,
Your help is greatly appreciated
-----Original Message-----
have
a button that once the date ranges are filled in the user
clicks to generate the report. I put the following code at
the begginging of the On Click event of the button:

If (IsNull(Me.txtBeginingDate) Or IsNull
(Me.txtEndingDate)) Then
MsgBox "Both Begining and Ending Date must be filled in"
Exit Sub
End If
Yhat way the report won't run until the user puts in both
dates.

I also check the value of the text boxes with the After
Update event to make sure the ending date is not before
the beginning date like this:

for the beginning date text box
If Me.txtBeginingDate > Me.txtEndingDate Then
MsgBox "The Begining date must be before the Ending date"
Me.txtBeginingDate = Null
End If

This code could also be in the On Click event of the
button as long as you put the Exit Sub line after the
Msgbox.
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top