Hi Folks,
I'm sure there is a simple explanation but I am stumped on how to ensure that a default value is used if a user doesn't select a start or end date in a form that feeds the between dates criteria in a simple query. Thanks in advance to anyone who can answer or point me to helpful documentation.
My form is called DateRange_form and has 3 Unbound text boxes for Start (txtStartDate), End (txtEndDate), and Clients (cboClients).
My query criteria for dates is: Between [Forms]![DateRange_form]![txtStartDate] And [Forms]![DateRange_form]![txtEndDate]
My query criteria for clients is: [Forms]![DateRange_form]![cboClients]
In the properties window for txtStartDate I set the Default Value to #1/1/2019# - have also tried using the = sign in front of #1/1/2019#
For txtEndDate I set the Default Value to = Date()
My form has two command buttons. One clears all data using VBA e.g. Me.txtStartDate = ""
The other button runs the query.
When I only select a client name from the combo box and leave the date fields empty I get an error message about the expression is typed incorrectly or is too complex to be evaluated.
The form works if I select dates from the date picker.
How come it appears as though the default values are not being recognized?
Bonus questions...
I also can't figure out how to set a default wildcard for the Clients combo box so if no client is select the query will pull up all clients within the date range.
Finally, I'm new to Access and I am unfamiliar with the ways to create and run macros, code, or expressions. Sometimes I'm offered 3 options when I select the build function in a properties sheet. Using VBA in Excel I can verify that a variable contains the correct data by looking at the properties window or doing a Debug.Print function as I walk through the code. I'm making the assumption that the unbound text box txtStartDate would be considered my first date variable. Is there a way I can see what value is about to be passed as criteria for the query?
Thanks,
Matt
I'm sure there is a simple explanation but I am stumped on how to ensure that a default value is used if a user doesn't select a start or end date in a form that feeds the between dates criteria in a simple query. Thanks in advance to anyone who can answer or point me to helpful documentation.
My form is called DateRange_form and has 3 Unbound text boxes for Start (txtStartDate), End (txtEndDate), and Clients (cboClients).
My query criteria for dates is: Between [Forms]![DateRange_form]![txtStartDate] And [Forms]![DateRange_form]![txtEndDate]
My query criteria for clients is: [Forms]![DateRange_form]![cboClients]
In the properties window for txtStartDate I set the Default Value to #1/1/2019# - have also tried using the = sign in front of #1/1/2019#
For txtEndDate I set the Default Value to = Date()
My form has two command buttons. One clears all data using VBA e.g. Me.txtStartDate = ""
The other button runs the query.
When I only select a client name from the combo box and leave the date fields empty I get an error message about the expression is typed incorrectly or is too complex to be evaluated.
The form works if I select dates from the date picker.
How come it appears as though the default values are not being recognized?
Bonus questions...
I also can't figure out how to set a default wildcard for the Clients combo box so if no client is select the query will pull up all clients within the date range.
Finally, I'm new to Access and I am unfamiliar with the ways to create and run macros, code, or expressions. Sometimes I'm offered 3 options when I select the build function in a properties sheet. Using VBA in Excel I can verify that a variable contains the correct data by looking at the properties window or doing a Debug.Print function as I walk through the code. I'm making the assumption that the unbound text box txtStartDate would be considered my first date variable. Is there a way I can see what value is about to be passed as criteria for the query?
Thanks,
Matt