Results 1 to 3 of 3
  1. #1
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    284

    Using SQL Table as RowSource For Access ListBox


    Hello...

    I'm ever so close to completing this project (Haha, no such thing) but at least for the moment my last hurdle is to populate my ListBoxes using SQL tables

    The following works great using a local/linked table
    Code:
    With Me
      .ListEmailAgnts.Visible = True
        .CmdSbmtNewNac.Visible = True
      .ListEmailAgnts.RowSource = "SELECT TblTmpTktEmail.EmpName, TblTmpTktEmail.EmpID " & _
                                                 "FROM TblTmpTktEmail"
    End With
    I'm trying to get the following code (and iterations thereof) to populate directly from the SQL Table
    Code:
    Dim conn As ADODB.Connection
    Set conn = New ADODB.Connection
    conn.ConnectionString = strConnection
    conn.Open
    
    With Me
     .ListEmailAgnts.Visible = True
      .CmdSbmtNewNac.Visible = True
    
    StrSQL = "SELECT tri.TktEmailTmp.EmpName, tri.TktEmailTmp.EmpID " & _
                  "FROM tri.TktEmailTmp"
    
    .ListEmailAgnts.RowSource = StrSQL  
    End With
    No errors - but ListBox is left empty

    Thanks for any help?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    link in the sql table as a table
    build a query
    set the listbox to this query

  3. #3
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    284
    Hey Ran Thanks for chiming in..

    I was kinda hoping to keep all the tables in SQL - (not even sure if that can be done)

    Either way, your solution works perfectly!

    Thanks again ranman

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

Similar Threads

  1. Table > Field > Lookup > RowSource
    By monvani in forum Access
    Replies: 2
    Last Post: 02-06-2016, 09:50 PM
  2. Reversing rowsource order for a multicolumn listbox
    By wackywoo105 in forum Programming
    Replies: 6
    Last Post: 12-10-2014, 06:26 AM
  3. Updating listbox rowsource not working
    By j2curtis64 in forum Forms
    Replies: 13
    Last Post: 12-07-2011, 01:46 PM
  4. RowSource Value not writing to the Table
    By tbassngal in forum Queries
    Replies: 5
    Last Post: 09-03-2011, 12:16 PM
  5. ListBox RowSource Update Not working in 2003
    By Access0307 in forum Programming
    Replies: 1
    Last Post: 05-05-2011, 07:41 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