Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2002
    Posts
    21

    Question Unanswered: Error using a query to filter dates for a report

    I am using a query to filter dates for a report. Basically, the query asks for a start date and a finish date, and then a report is generated. The problem is that if you enter "010302" instead of "01/03/02" or anything besides XX/XX/XX it generates an error ("this expression is typed incorrectly..."). If I put code under on error in the report, it shows my message box, then the same access error. How do I get rid of this? Also, is there a way to apply an input mask on a query's inputbox? Thanks! John

  2. #2
    Join Date
    Aug 2002
    Posts
    4

    Dates

    The best and neatest way to achieve this is to define a menu form through which you enter the date values. If you do it this way you can write code in vB to allow you to accept anything that looks like a date and convert it into the format your query expects.


  3. #3
    Join Date
    Aug 2002
    Posts
    21
    If I make a form with two textboxes for the start and stop dates, how do I code it to filter? I know how to do this with a query but I do not know how to just with VBA.

  4. #4
    Join Date
    Aug 2002
    Posts
    4

    Link Text Boxes to query

    There are two ways.

    The simplest is to replace your inputs in the query with references to the textboxes on your form. You can use expression builder from within the query in design view to do this.

    Another way is to define two functions that return the values input in each respective textbox and use the functions instead of the inputs in your query.

    The later is a more general solution that allows input variable values to be kept and used whenever you want.


Posting Permissions

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