I want a query to run and output values on a certain date. I have created a form and inserted an activex component 'Microsoft Date & time picker'.
This control is just a fancy method of entering a date/[time] so it works pretty much the same as any regular text control when it comes to referencing it and using it in forms, queries and the like.
Originally Posted by iso96
But im stuck on how to get this component to be recognised by the query! Can anyone please help me out or suggest a different way?
The fact that you are using an activeX control rather than a regular text box is largely irrelevant. The real question is how you can use an entry in a control to make a filtered selection. There are many ways of doing this.
I suspect the following isn't what you want exactly but follow it through as it will explain some useful principles...
If you have a 'Microsoft Date & time picker' control called myControlName on a form called myFormName then you can reference the value of a control like this:
This will most likely return a datestamp which is a long string of date and time which isn't useful as you can't match on time. So we use this which will return just the date part:
You could stick this in the condition for your query so that when you select a date on your form and then open your query, the query will show only the records for the given date.
- Create a blank form with no record source
- Add the 'Microsoft Date & time picker' (unbound)
- Create a query based on your recordset
- add the condition: DateValue(Forms![myFormName]![myControlName].value)
- Select a date on your form
- run the query (the form must still be open for the condition to be read from it)
If you get that working then you can use the principle to do things like filter the records in your form rather than in a seperate query (although I might need to do a bit more explaining if we get this far).
I am using Microsoft's Date/Time Picker 6.0 in an MS Access application. My question is, how can I instruct it to default to the CURRENT date? If I double-click and open the ActiveX properties dialog, it allows me to pick a static date as the default date. If I right-click and open the control properties dialog, it does not allow me to use the "Date" or "Now" Access functions.
How can I set it to default to the current date on the user's machine?