Results 1 to 4 of 4
  1. #1
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581

    Multiple Where Command

    I'm trying to add a where command to a button. I need it to be multiple wheres. I wrote this and it went straight to the debugger.
    DoCmd.OpenForm "frmSchTimeSheet", , , ("EmployeesID=" & Me.cboEmployee And "BeginDate=" & Me.txtBeginDate And "EndDate=" & Me.txtEndDate)
    I'm really hoping this is possible.

  2. #2
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    Figured it out.
    DoCmd.OpenForm "frmSchTimeSheet", , , "EmployeesID = forms!frmSchTimeSheet!cboEmployee And BeginDate = forms!frmSchTimeSheet!txtBeginDate And EndDate = forms!frmSchTimeSheet!txtEndDate"

  3. #3
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Dates and Text require delimiters...
    Consider
    Code:
    DoCmd.OpenForm "frmSchTimeSheet", , , "EmployeesID = " & Me.cboEmployee & " And BeginDate = #" & Me.txtBeginDate & "# And EndDate = #" & Me.txtEndDate & "#"
    OR
    Code:
    DoCmd.OpenForm "frmSchTimeSheet", , , "EmployeesID = " & forms!frmSchTimeSheet!cboEmployee & " And BeginDate = #" & forms!frmSchTimeSheet!txtBeginDate & "# And EndDate = #" & forms!frmSchTimeSheet!txtEndDate & "#"


    -----------------------------------------------------------------
    I like to create a string so I can check to ensure the Where clause is properly formed:
    Code:
    Dim strWhere as String
    
      strWhere = "EmployeesID = " & Me.cboEmployee & " And BeginDate = #" & Me.txtBeginDate & "# And EndDate = #" & Me.txtEndDate & "#"
    
      Debug.Print strWhere 
    
      DoCmd.OpenForm "frmSchTimeSheet", , , strWhere

  4. #4
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    I keep forgetting about that. Thanks.

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

Similar Threads

  1. Printing Multiple Bills in a sngle command
    By deepakg27 in forum Reports
    Replies: 11
    Last Post: 05-31-2018, 11:07 PM
  2. Add Command Button to Multiple Forms
    By jameslefebv in forum Forms
    Replies: 4
    Last Post: 07-14-2014, 07:07 PM
  3. BAT command to combine multiple files
    By dekutoski in forum Import/Export Data
    Replies: 1
    Last Post: 08-09-2013, 08:32 AM
  4. Replies: 13
    Last Post: 02-23-2011, 08:38 AM
  5. Printing multiple reports with one command
    By AKQTS in forum Reports
    Replies: 2
    Last Post: 09-24-2010, 09:32 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