While there is no built in 'Time Picker' you could add two unbound combo
boxes, cboTimeFrom and cboTimeTo, to the form and fill them with code in the
form's Open event procedure. To list all times from midnight until 11:45 PM
in 15 minute steps for instance the code would be:
Dim dtmTime As Date
Dim dblInterval As Double
dblInterval = 1 / (24 * 4)
Me.cboTimeFrom.RowSourceType = "Value List"
Me.cboTimeTo.RowSourceType = "Value List"
For dtmTime = #12:00:00 AM# To #11:45:00 PM# Step dblInterval
Me.cboTimeFrom.AddItem Format(dtmTime, "hh:nn AM/PM")
Me.cboTimeTo.AddItem Format(dtmTime, "hh:nn AM/PM")
Next dtmTime
Your Query would then be like this:
PARAMETERS
Forms![Form1]![DateFrom] DATETIME,
Forms![Form1]![DateTo] DATETIME,
Forms![Form1]![cboTimeFrom] DATETIME,
Forms![Form1]![cboTimeTo] DATETIME;
SELECT *
FROM [YourTable]
WHERE DATEVALUE([YourDateField])
BETWEEN Forms![Form1]![DateFrom]
AND Forms![Form1]![DateTo]
AND TIMEVALUE([YourDateField])
BETWEEN Forms![Form1]![cboTimeFrom]
AND Forms![Form1]![cboTimeTo];
ORDER BY [YourDateField];
You can either open another form with this query as its RecordSource property
from a button on Form1, or you can make the RecordSource of Form1 the above
query and include controls bound to the fields returned by the query on the
form, in which case you'd just requery the form in the button's Click event
procedure with:
Me.Requery
Ken Sheridan
Stafford, England
Little said:
My goal is to end up with a query where Ican use the DTpicker from a
form. Is this not possible?
[quoted text clipped - 6 lines]
Could you explain what you're trying to accomplish, and what's the context?