Calendar control wont work with VBA query

tt1611

Registered User.
Local time
Today, 16:22
Joined
Jul 17, 2009
Messages
132
This question involves VBA as well so i hope i am in the right area. I have a form that has 2 combo boxes and a calendar control. I also have a datasheet subform in the form. I have set both combo boxes to call the calendar on mouse down and whatever date is selected off the calendar writes to the combo box no problem.

I wish to execute a query based on date_from and date_to as selected from the calendar and display the results in the subform. Without the calendar control, if the user manually enters dates in both fields by typing them in, the query works fine; however if the dates are selected from the calendar nothing happens. My code for the dates have been inputted in the after_update event which like i mentioned above works fine without the calendar control

Has anyone experienced this before and if so do you know how to get around this. Its just for ease of use to the customer to be able to select the date and then search. I have not included a search button on the form because i have several other search criteria that the use can use to include combos, checkboxes and textboxes hence every control has been hard coded to output results after update.
 
Use the Click event of the calendar control to set the value of a TEXT BOX (hidden) and use that for the query.
 
thats exactly what i'm doing. On mouse down/click, the calendar is called, date is selected from calendar to combo by the on_click event without any problems but its as though the form is not updating the combo box when a date value is selected because after_update on the combo, a query should automatically run.
 
thats exactly what i'm doing. On mouse down/click, the calendar is called, date is selected from calendar to combo by the on_click event without any problems but its as though the form is not updating the combo box when a date value is selected because after_update on the combo, a query should automatically run.

After update events don't run if controls are set by code. You can call the After Update event of the combo directly from the other event.
 
After update events don't run if controls are set by code. You can call the After Update event of the combo directly from the other event

Bob I hope i'm not being a pain but i dont understand what you are saying here.
 
Bob I hope i'm not being a pain but i dont understand what you are saying here.

Just setting the combo box's value from code does not fire the After Update event of the combo box. You would need to call the combo's After Update event from the same place where you set the value. You might need to change the After Update event of the combo box to be PUBLIC instead of PRIVATE.

PUBLIC YourComboBoxNameHere_AfterUpdate()
...etc.
End Function

and then call it like

Forms!YourFormNameHere.YourComboBoxNameHere_AfterUpdate
 

Users who are viewing this thread

Back
Top Bottom