Results 1 to 2 of 2
  1. #1
    dbeelow@comcast.net is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2013
    Posts
    1

    Access/SQL Server .adp (project) ado programming

    All I'm trying to do is fill in a list box. I have multiple columns in the list box but the index on additems does not work. I've tried every permutation I can think of. No luck. I give up.

    How do I fill in a access list box from a SQL table all in a "project" ADO?

    Dim rsRMFind As New ADODB.Recordset

    Set rsRMFind = New ADODB.Recordset

    rsRMFind.Open "select * from Client_Info where [cli_Org_ID] = '" & Me!SearchFor & "'", CurrentProject.Connection, adOpenStatic

    rsRMFind.MoveFirst

    i = 0
    With Me.SearchResults

    Do
    ListIndex(i, 0).AddItem rsRMFind!cli_Company_Name
    ListIndex(i, 1).AddItem rsRMFind!cli_Org_ID
    Me.SearchResults.Column(1).AddItem rsRMFind!cli_Org_ID
    i = i + 1
    rsRMFind.MoveNext


    Loop Until rsRMFind.EOF
    End With

  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
    Do you have established link to the SQL table? If so, why not just set the RowSource property of combobox to a query or SQL statement? What is Me!SearchFor - a field on form?

    Sounds like you are trying to do dependent (cascading) comboboxes. Set the RowSource to:

    SELECT cli_Company_Name, cli_Org_ID FROM Client_Info WHERE cli_Org_ID = [SearchFor];

    Then in SearchFor AfterUpdate event:

    Me.SearchResults.Requery

    However, if this on a continuous or datasheet form, will not work nice.
    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.

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

Similar Threads

  1. VBA Programming of P_I Matrix in Access
    By Bretz217 in forum Programming
    Replies: 19
    Last Post: 02-25-2013, 08:20 AM
  2. Programming Access - is there a quicker\better way?
    By shabbaranks in forum Programming
    Replies: 2
    Last Post: 08-25-2012, 10:42 AM
  3. Access Programming issue i think???
    By whitey in forum Programming
    Replies: 3
    Last Post: 01-03-2012, 01:15 PM
  4. New to programming in MS access 2007...
    By DarrenReeder in forum Programming
    Replies: 5
    Last Post: 12-05-2010, 01:03 PM
  5. New to Access programming
    By pushpm in forum Programming
    Replies: 1
    Last Post: 02-20-2009, 03:03 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