Results 1 to 4 of 4
  1. #1
    CharissaBelle is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2016
    Posts
    81

    SQL WHERE clause with an AND in VBA


    I'm using a SQL query inside of VBA code on a combobox's afterupdate event.

    Right now, I have everything working except I want to set the WHERE clause to have an AND. I want to say WHERE City_ID =" & Me.cboCity AND Vendor_ID =" & Me.cboVendor. How do I write this?

    Thank you for any help you can give me.

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    if writing in vba

    criteriastr="WHERE City_ID =" & Me.cboCity & " AND Vendor_ID =" & Me.cboVendor

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Almost had it. Missing a couple of quotes. If Me.cboCity and Me.cboVendor are numbers, then try:
    Code:
    sSQL ="SELECT blah FROM Table WHERE City_ID = " & Me.cboCity  & " AND Vendor_ID = " & Me.cboVendor

  4. #4
    CharissaBelle is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2016
    Posts
    81
    That's it! Thank you! I knew I was just missing something simple.

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

Similar Threads

  1. Need help with a WHERE clause
    By DB88 in forum Access
    Replies: 10
    Last Post: 06-11-2014, 01:40 PM
  2. Max within a where clause
    By kdayboll in forum Queries
    Replies: 2
    Last Post: 09-14-2013, 12:13 PM
  3. Using Where Clause
    By mbrinser in forum Programming
    Replies: 2
    Last Post: 12-29-2011, 04:09 PM
  4. Using the TOP clause
    By WSlepecki in forum Queries
    Replies: 1
    Last Post: 04-08-2011, 06:59 AM
  5. Help on WHERE clause
    By QBCM in forum Programming
    Replies: 1
    Last Post: 12-19-2005, 08:43 PM

Tags for this Thread

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