Results 1 to 5 of 5
  1. #1
    Auto is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2013
    Posts
    60

    ListBox Row Source Query With Global Var

    hi, i have a form which has a combobox which the user needs to choose a phone number from a customer, after update, vba places the value in a variable, then i have listbox that needs to show up for the customer with all orders from that phone number.



    so i placed a Sql string for the Raw Source in vba, but nothing pulls up, here is my code.

    Dim SQL As String

    SQL = "SELECT DISTINCT Orders.PurchaseDate, Orders.OrderID" _
    & "FROM Orders INNER JOIN Customers ON Orders.CustomerID = Customers.ID" _
    & "WHERE Customers.Phone = '" & PhoneNum & "'"


    Me.OrderList.RowSource = SQL
    Me.OrderList.Visible = True
    can anyone tell why its not working?
    thanks in advanced.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Need embedded space in the SQL string after Orders.OrderID and Customers.ID. Without embedded spaces the segments run into each other when concatenated.
    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
    Auto is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2013
    Posts
    60
    oh man, you got it, how dumb am i

    but it show up only the date, which is column 1, not the column 2 which is OrderID
    how can i get both columns to show up?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Set the ColumnCount and ColumnWidths properties of combobox.
    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.

  5. #5
    Auto is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2013
    Posts
    60
    got it, thanks a billion!

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

Similar Threads

  1. Replies: 2
    Last Post: 03-23-2014, 06:50 AM
  2. Requery Does Not Update Listbox Row Source
    By szucker1 in forum Forms
    Replies: 7
    Last Post: 02-11-2014, 08:58 AM
  3. Replies: 8
    Last Post: 10-09-2013, 02:09 AM
  4. Replies: 4
    Last Post: 07-14-2011, 12:55 PM
  5. Dlookup in query using Global variable
    By newwales in forum Access
    Replies: 1
    Last Post: 06-03-2011, 03:47 PM

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