Results 1 to 8 of 8
  1. #1
    Suzied is offline Novice
    Windows XP Access 2002
    Join Date
    Mar 2010
    Posts
    6

    Red face Writing between criteria in a form

    Good Day;



    I have written a query which uses the between criteria to select data within a date range.

    I would like users to access query from a form, with the option to specify the date range which is in the criteria.

  2. #2
    Gerry is offline Rusty Developer
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    Kings Mountain, NC
    Posts
    33
    I'm with you so far - what is your hold-up? What are you trying to do that you're not able to accomplish?

  3. #3
    Suzied is offline Novice
    Windows XP Access 2002
    Join Date
    Mar 2010
    Posts
    6
    I don't know how to get the range which is in the criteria on the form.

  4. #4
    Gerry is offline Rusty Developer
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    Kings Mountain, NC
    Posts
    33
    Okay, if I understand correctly, your problem is that you don't know how to take the entry from the form and use it for criteria in the query. This isn't too hard, actually. I'll skip some of the details - if you need more, let me know.

    Put a button on your form to run the query (or to update the query). Also, add two date fields (in my example, dtStart and dtEnd). I'm assuming you've set up the query already, and tested it with hard-coded dates as criteria, to make sure it works properly. Assuming the form is frmLookup, you'd just replace the hard-coded dates with the form field names, so you'd have something like this in your criteria for the appropriate date field in your query:

    >= [frmLookup]![dtStart] AND <= [frmLookup]![dtEnd]

    Now, when they click the "search" button (or whatever you label it) to call the query results, the query will base the results on the entries in these fields.

    There are other ways, but this should do what you want.

  5. #5
    Suzied is offline Novice
    Windows XP Access 2002
    Join Date
    Mar 2010
    Posts
    6

    Form - Update Query with values from Form

    Hi Gerry;

    This works, but it asking me for the Parameter values before the form is even open. Then it ask me for the value again when the form is and the command button is submitted.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I would use Between (though the other way works), and the correct syntax includes "Forms!" before the form name:

    Between Forms!FormName.ControlName And Forms!FormName.OtherControlName

    The form must be open when the query runs. Typically we open the criteria form, let the user enter the dates, and then open the form or report that uses the query from that form. You can open the criteria form in dialog mode from the open event of the report as well, but it's probably less common.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Suzied is offline Novice
    Windows XP Access 2002
    Join Date
    Mar 2010
    Posts
    6
    Now this worked. Thanks

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Writing Access functions
    By new2access123 in forum Programming
    Replies: 5
    Last Post: 02-06-2010, 10:47 PM
  2. Automatically Writing SQL From A Table
    By smitstev in forum Programming
    Replies: 1
    Last Post: 06-05-2009, 09:38 AM
  3. Help writing multiple queries
    By wz72n01 in forum Queries
    Replies: 1
    Last Post: 05-24-2009, 12:30 PM
  4. I need help writing a query statement
    By dking in forum Queries
    Replies: 1
    Last Post: 02-25-2009, 09:43 AM
  5. Force writing from the right in a field?
    By Looping in forum Forms
    Replies: 0
    Last Post: 01-23-2006, 03:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums