Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2005
    Posts
    16

    Unanswered: date time picker

    hello,

    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'.

    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?

    thanks

    iso

  2. #2
    Join Date
    Jul 2004
    Location
    Southampton, UK
    Posts
    368
    iso
    Quote Originally Posted by iso96
    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.

    Quote 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:
    Forms![myFormName]![myControlName].value

    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:
    DateValue(Forms![myFormName]![myControlName].value)

    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.

    To summarise:
    - 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).

    hth
    Chris

  3. #3
    Join Date
    Mar 2005
    Posts
    16
    Excellent reply thankyou very much. Got it working!

    Thanks again

    iso

  4. #4
    Join Date
    Sep 2005
    Location
    North Carolina, USA
    Posts
    11
    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?

    Thanks in advance,
    Jason

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •