Results 1 to 4 of 4
  1. #1
    tmartin is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Mar 2015
    Posts
    37

    Question How do I merge two Queries into one?

    Each of these word independently but want to combine them into whereis field into one



    DoCmd.OpenForm "TransactionsForm", acNormal, "Query4Search", "[EmployeeID]=[Forms]![LoginForm]![cboUser]", acReadOnly, acNormal


    DoCmd.OpenForm "TransactionsForm", acNormal, "Query4Search", "[Date] >= #" & Me.StartDate & "# AND [Date] <= #" & Me.EndDate & "#", acReadOnly, acNormal

    Your help would be greatly appreciated
    Tom

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,740
    You could review the info at this link and see if it helps.
    Create your where clause with multiple criteria. Similar to his sWhere clause

    (untested)
    Code:
     Dim sWhere as string
    sWhere =  "[EmployeeID]= " & [Forms]![LoginForm]![cboUser]  _
     & " AND  [Date] Between #" & Me.StartDate & "# AND   #" & Me.EndDate & "#"

  3. #3
    tmartin is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Mar 2015
    Posts
    37
    It worked great!
    I also have another requirement to do a query for today's and 3 months of transactions. I looked at the Duration: DateDiff("d",[Date],Date())
    I was trying to combine the EmployeeID with the DateDIff function to provide the output that I need. Can you give some insight on how you would approach it?
    THanks again

    Quote Originally Posted by tmartin View Post
    Each of these word independently but want to combine them into whereis field into one

    DoCmd.OpenForm "TransactionsForm", acNormal, "Query4Search", "[EmployeeID]=[Forms]![LoginForm]![cboUser]", acReadOnly, acNormal


    DoCmd.OpenForm "TransactionsForm", acNormal, "Query4Search", "[Date] >= #" & Me.StartDate & "# AND [Date] <= #" & Me.EndDate & "#", acReadOnly, acNormal

    Your help would be greatly appreciated
    Tom

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,740
    You have the EmployeeID part and a generic method to deal with Dates.

    So what exactly is the Date criteria. (Note: Date is a reserved word in access/vba)

    Are you asking for >=Today and 90 days from today?
    90 days from today is Date() + 90

    or DateAdd("d",90,Date())
    You should be able to use the previous answer to build a new sqlString.
    see http://www.techonthenet.com/access/f...te/dateadd.php

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

Similar Threads

  1. Replies: 1
    Last Post: 12-03-2014, 06:41 PM
  2. Replies: 9
    Last Post: 08-27-2014, 11:34 AM
  3. Merge 2 queries with null? values
    By PrintShopSup in forum Queries
    Replies: 2
    Last Post: 10-03-2011, 09:09 PM
  4. Mail Merge data source queries missing
    By UTS in forum Queries
    Replies: 6
    Last Post: 09-21-2011, 01:48 AM
  5. Replies: 5
    Last Post: 08-29-2011, 09:37 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