Results 1 to 4 of 4
  1. #1
    anunat is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    19

    Form Filter Question

    I have a form that has four combo boxes

    FromMonth, FromYear, ToMonth, ToYear



    I have a dropdown list for each of them. I am doing it this way, because the data comes in once every month. So only month and year are relevant.

    I use the following code to convert them to date format:

    fromdate = DateValue(Me.Frommonth & "/" & "01/" & Me.Fromyear)

    todate = DateValue(Me.Tomonth & "/" & "01/" & Me.Toyear)

    My table has a date field. I would like to run a query from the above form for all dates between fromdate and todate.

    How do I do this?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,943
    The query can reference the boxes as input parameters.

    Where do you have the fromdate and todate calculations - in textbox ControlSource?

    SELECT * FROM tablename WHERE datefield BETWEEN DateValue(Forms.formname.Frommonth & "/01/" & Forms.formname.Fromyear) AND DateValue(Forms.formname.Tomonth & "/01/" & Forms.formname.Toyear);
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    anunat is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    19
    I was not sure where to put the fromdate and fromyear calculations actually. Can you please explain how to do that?

  4. #4
    anunat is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    19
    I put the calculation in the controlsource and tried this. It worked. Thank You Thank You Thank You

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

Similar Threads

  1. Replies: 28
    Last Post: 03-08-2012, 06:47 PM
  2. Text Box Filter Question
    By ShadeRF in forum Forms
    Replies: 4
    Last Post: 06-07-2011, 07:58 AM
  3. Combo-Box Filter/Autocomplete Question
    By jhcarrell in forum Forms
    Replies: 4
    Last Post: 11-02-2010, 12:46 PM
  4. Replies: 1
    Last Post: 08-25-2010, 09:43 AM
  5. Newbie filter question
    By benplace in forum Access
    Replies: 1
    Last Post: 12-03-2005, 08:31 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