Results 1 to 6 of 6
  1. #1
    Swatskeb is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    23

    Qbf using same query but different forms and values

    I have a totals report based on a query the qbf is for the date input field. I want to be able to run this report from two separate forms the first form is for users where they select the month and year from a combo box the criteria looks like below this is done to ensure users only run monthly or yearly reports to limit the chance of picking the wrong dates

    Like [Forms]![Switchboard_Form]![Month] & "*" & [Forms]![Switchboard_Form]![Year]

    I have another form that is sort of the Management Form in which the qbf Totals report can be run more in depth such as a certain range maybe for a certain week by using start date and end date the criteria looks like below

    >=Nz([Forms]![Managment_Form]![From],#01/01/100#) And <=Nz([Forms]![Managment_Form]![To],#12/31/9999#)

    This lets totals be pulled using both, none, or one or the other of the start date and end date

    Is there a way I can set up the query to tell which form is open and to use the correct criteria for that particular form. I tried using "or" however the query still prompts for the other set of values no matter which form u use but works fine when you remove the not needed criteria. I can provide a better example if needed let me know if this is unclear.

    Thanks

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    Thats the thing, if you use 2 forms, then you need 2 queries to point to the different form critiera.

    I've had this too, so I created a 3rd form that stores the criteria created form the other 2.
    When the user clicks RUN, all the data in the controls is copied to the 3rd form, and all queries run off that.

  3. #3
    Swatskeb is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    23
    I'm not sure I understand because even if I have 2 forms into one form how do I tell the query which data type is in the 3rd form for example if I have a data type that is month value 1-12 and year. And another set of data that is start date and end date what do I need to put in the qbf to tell it to use either set of criteria from the original post. The report doesn't both sets of criteria at the same time so there is no reason to have to save all four values just one set or the other set.

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    The form doesnt care about data type.

    All the queries would need to change to reference the 3rd form.....forms!frm3rd!txtStartDate.
    Using your forms, on RUN click, transfer all fields to the 3rd form:

    [Forms]![frm3rd![Month] = [Forms]![Switchboard_Form]![Month]
    [Forms]![frm3rd![Year] = [Forms]![Switchboard_Form]![Year]

    then run the query.

  5. #5
    Swatskeb is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    23
    >=Nz([Forms]![Managment_Form]![From],#01/01/100#) And <=Nz([Forms]![Managment_Form]![To],#12/31/9999#)

    Above would be the query formula that I would use for start/end date and below would be what I would be using for month & year

    Like [Forms]![Switchboard_Form]![Month] & "*" & [Forms]![Switchboard_Form]![Year]

    So if I had only two txt boxes on the 3rd form and I could have the values of 5 & 2014 for month & year or I can have 3/1/2014 & 4/30/2014 for start & end date (completely different sets of dates. I can put the two formulas in the same query separated on two lines using (Or) as long as both the formulas call the same two txt boxes?

  6. #6
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    As long as the boxes have the same name, you can put anything in the box.

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

Similar Threads

  1. Default Values/Forms/Macros?
    By sivega in forum Access
    Replies: 1
    Last Post: 07-26-2013, 02:05 PM
  2. Replies: 3
    Last Post: 07-30-2011, 09:12 PM
  3. passing values between forms
    By paulw in forum Access
    Replies: 4
    Last Post: 06-15-2011, 08:52 AM
  4. PASSING Values between Forms
    By chhinckley in forum Programming
    Replies: 1
    Last Post: 08-27-2010, 10:19 AM
  5. Table values in forms
    By xzxz in forum Access
    Replies: 3
    Last Post: 10-28-2008, 08:29 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