Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2003
    Posts
    5

    Exclamation Unanswered: Filter form by specific date from text box

    All I need to do is filter all records in the table by a specific project start date that will be typed in by the user in the text box.

    Should I use lostfocus, change or what function.

    And how would I go about filtering the records with that specific date that was inputted??

    Can someone please help me...
    Thank you

  2. #2
    Join Date
    Jan 2003
    Location
    Dordrecht, The Netherlands
    Posts
    95

    Re: Filter form by specific date from text box

    I usually add a button that performs the filter action with its Click event.

    Filtering on dates is a bit cumbersome, the filter string should be something like:
    "ProjectStartDate = #" & Format(CDate(txtDate),"mm/dd/yyyy") & "#"

    Irrespective of you regional settings, you always have to use the American date format in Access SQL and VB/VBA.

    Originally posted by sokol18
    All I need to do is filter all records in the table by a specific project start date that will be typed in by the user in the text box.

    Should I use lostfocus, change or what function.

    And how would I go about filtering the records with that specific date that was inputted??

    Can someone please help me...
    Thank you

  3. #3
    Join Date
    Jun 2003
    Location
    USA
    Posts
    1,032
    Well here is a query by form example using TWO dates as criteria:

    Have a form perhaps called MyForm with the following 2 controls:
    ctrDateMin
    ctrDateMax

    And have a command button on the form to open the report with something like the following code behind the OnClick property:
    DoCmd OpenReport "MyReport", A_PREVIEW
    DoCmd Maximize

    Of course the form could also have a command button to open another form with something like the following code behind the OnClick property:
    DoCmd OpenForm "MyOtherForm"
    DoCmd Maximize

    Base the report on a query. In the query's criteria for the date field perhaps put in something like the following:
    Between [Forms]![MyForm]![ctrDateMin] And [Forms]![MyForm]![ctrDateMax]

    And of course if the command button were opening a form instead of a report, the form could also be based on the same query or a similar one.
    J. Paul Schmidt, Freelance Web and Database Developer
    www.Bullschmidt.com
    Access Database Sample, Web Database Sample, ASP Design Tips

  4. #4
    Join Date
    Mar 2003
    Posts
    5

    Re: Filter form by specific date from text box

    Thank you Ad, you were very helpful, and yes it was a bit cumbersome until you told me the proper format... thanks again





    Originally posted by Ad Dieleman
    I usually add a button that performs the filter action with its Click event.

    Filtering on dates is a bit cumbersome, the filter string should be something like:
    "ProjectStartDate = #" & Format(CDate(txtDate),"mm/dd/yyyy") & "#"

    Irrespective of you regional settings, you always have to use the American date format in Access SQL and VB/VBA.

Posting Permissions

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