Combobox showing List of tables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Alireza355
    New Member
    • Feb 2009
    • 86

    Combobox showing List of tables

    Dear all,

    I would like to know if there is a way to have a combobox in an unbound form to show only the names of tables starting with numbers. eg. 88 , 89, 90, etc.

    Best Regards,
    Alireza355
  • PianoMan64
    Recognized Expert Contributor
    • Jan 2008
    • 374

    #2
    Originally posted by Alireza355
    Dear all,

    I would like to know if there is a way to have a combobox in an unbound form to show only the names of tables starting with numbers. eg. 88 , 89, 90, etc.

    Best Regards,
    Alireza355
    Hey Alireza355,

    Welcome.

    Can you please post your code and show me what it is that you're speaking of. Since I dont' know how you're loading the Combo Box control, the answer is going to depend on the method used.

    Thanks,

    Joe P.

    Comment

    • Alireza355
      New Member
      • Feb 2009
      • 86

      #3
      Combobox

      Dear PianoMan64,

      I have created a database, with a lot of tables, forms and reports, etc. almost all the table names are not numberical. For example: Credit, Debit, Expenses, Codes, etc.

      but some tables names are numerical. Example: 88, 89, 90, 91, etc.

      I have an unbound form, asking the user to select one of the previous years, and the command button in that form does all the exchanges, table renames, calculations, updates, etc.

      I just want the combobox in that form to show the names of tables which start with numbers.

      Thanx a lot

      Comment

      • DonRayner
        Recognized Expert Contributor
        • Sep 2008
        • 489

        #4
        This function will return a value list of tables that start with an integer. You can then use the forms "on open" or any other event to set the combobox.rowsou rce value.

        Code:
        Public Function ListTables()
            Dim i As Integer
            Dim s As String
            On Error Resume Next
            For i = 0 To CurrentDb.TableDefs.Count - 1
                s = CurrentDb.TableDefs(i).Name
                If Val(s) > 0 Then
                    If ListTables = "" Then
                        ListTables = s
                    Else
                        ListTables = ListTables & "; " & s
                    End If
                End If
            Next
        End Function
        And the code for setting the rowsource would be.

        Code:
        Private Sub Form_Open(Cancel As Integer)
        ComboBoxName.RowSource = ListTables()
        End Sub

        Comment

        • Alireza355
          New Member
          • Feb 2009
          • 86

          #5
          Thanx a lot

          WOW!

          You are a nuclear bomb........


          Thanx a loooooooooooooo ooooooooooooooo ooooooooooooot

          Comment

          • DonRayner
            Recognized Expert Contributor
            • Sep 2008
            • 489

            #6
            You're quite welcome. Good luck with your project

            Don

            Comment

            • Alireza355
              New Member
              • Feb 2009
              • 86

              #7
              One More Thing

              Dear Don,

              First of all, I would like to thank you again for your kind help.

              My accounting project is finally finished, and working perfectly. But there is one last thing I would like to have deep knowledge on, and since you are an expert, I would like to ask you to have a look at another thread I have started on March 7th, called "Lock Records", and see if you can provide help.

              Thank you very much, and with all the best wishes.

              Comment

              Working...