Results 1 to 4 of 4
  1. #1
    HS_1 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2016
    Posts
    118

    Show table names in combobox


    I am trying to list table names in a combo box row source set to Value List. When I Debug.Print the combo box it shows in immediate window all the table names I need however combobox displays only the last table name. Have no idea how to fix the function so all tables are listed in combobox row source.

    Code:
    Dim db As DAO.Database
    Dim tdf As DAO.TableDef
    Set db = CurrentDb
    Me.cboPipeAllowTable.RowSource = ""
    For Each tdf In db.TableDefs
        
         If tdf.Name Like "tblPipeAllow(*)" Then
         Me.cboPipeAllowTable = tdf.Name
            
            Debug.Print cboPipeAllowTable
        End If
    Next
    Set tdf = Nothing
    Set db = Nothing

  2. #2
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,879
    Code:
         If tdf.Name Like "tblPipeAllow(*)" Then
    
          Me.cboPipeAllowTable.AddItem  tdf.Name
            
        End If
    https://learn.microsoft.com/en-us/of...mbobox.additem
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  3. #3
    HS_1 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2016
    Posts
    118
    Quote Originally Posted by moke123 View Post
    Code:
         If tdf.Name Like "tblPipeAllow(*)" Then
    
          Me.cboPipeAllowTable.AddItem  tdf.Name
            
        End If
    https://learn.microsoft.com/en-us/of...mbobox.additem
    moke123
    Thank you for the replay, I tried .AddItem as you suggested but it returns Null in immediate window, and combobox is empty ?

  4. #4
    HS_1 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2016
    Posts
    118
    Moke123, I revised the combobox column count and widths, corrected it and the suggested changes to the code by you pull the right values
    Thank you one more time

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

Similar Threads

  1. Replies: 2
    Last Post: 07-17-2022, 02:57 AM
  2. Replies: 7
    Last Post: 03-05-2016, 03:04 PM
  3. Replies: 1
    Last Post: 03-01-2016, 06:05 AM
  4. Replies: 1
    Last Post: 04-26-2013, 05:30 PM
  5. Replies: 5
    Last Post: 07-04-2011, 10:11 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