I am using Access 2010, and trying out the Navigation Form feature.
I have a form under a tab where I have created two MS Date/Time Selector ActiveX controls. I have the default value set as Today. One is a Start Date and one is an End Date.
Once the user has made their selections, I want to store the results of these 2 fields in public variables. Then I will use these variables in queries to filter my results for stuff that lies between these 2 dates. I have several reports that need to be run using whatever date range the user selects.
If the user leaves the form and returns, then I want their selection retained so the start date is the value they have chosen, not Today.
I am able to store other user selections (text mainly) as public variables, but not these dates. I'm not sure what I'm doing wrong.
In a Module, I have:
And on the form, I have an Enter script on the StartDate as:
On the form's OK button I have:
Do I have to do it this way? No, I am open to other suggestions. I don't want the user to have to select 3 different variables for the start date, though, so the MSDate ActiveX is really the best option.
The line that is giving me errors is supposed to be looking at the public variable. If there is no value then set it to be today. If there IS a value, use THAT value to prepopulate the field. I have tried If varStartDate = 0 but that didn't work either.
Help? Please?
I have a form under a tab where I have created two MS Date/Time Selector ActiveX controls. I have the default value set as Today. One is a Start Date and one is an End Date.
Once the user has made their selections, I want to store the results of these 2 fields in public variables. Then I will use these variables in queries to filter my results for stuff that lies between these 2 dates. I have several reports that need to be run using whatever date range the user selects.
If the user leaves the form and returns, then I want their selection retained so the start date is the value they have chosen, not Today.
I am able to store other user selections (text mainly) as public variables, but not these dates. I'm not sure what I'm doing wrong.
In a Module, I have:
Code:
Function Declarate()
Public varStartDate As Date
Public varEndDate As Date
End Function
And on the form, I have an Enter script on the StartDate as:
Code:
Public Sub StartDate_Enter()
If Not varStartDate Is Null Then ' ***This line is giving me errors.
Me.StartDate = varStartDate
Else
Me.StartDate = Now()
End If
End Sub
On the form's OK button I have:
Code:
Private Sub OKDate_Click()
varStartDate = Me.StartDate
varEndDate = Me.EndDate
End Sub
Do I have to do it this way? No, I am open to other suggestions. I don't want the user to have to select 3 different variables for the start date, though, so the MSDate ActiveX is really the best option.
The line that is giving me errors is supposed to be looking at the public variable. If there is no value then set it to be today. If there IS a value, use THAT value to prepopulate the field. I have tried If varStartDate = 0 but that didn't work either.
Help? Please?