Results 1 to 4 of 4

Thread: Load ComboBox in Module

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 1999
    Location
    SANTA ANA
    Posts
    14

    Question

    How can I load a comboBox (CmbFirstName)that is on frmCustomers inside a standard module(mdlCustomers).

  2. #2
    Guest

    Thumbs up

    Something like this

    with frmCustomers.cmdFirstName
    .Clear
    .Additem Firstname or whatever
    .ListIndex = 0
    End With

    Of course you would loop on the name additions.

    Hope it Helps

  3. #3
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Lightbulb

    If you want that procedure to be reusable, then you can so something like this:

    Module Code
    Code:
    Public Sub LoadCombo(pCombo As Combobox)
        With pCombo
            .Clear
            .AddItem "John"
            .AddItem "Mike"
        End With
    End Sub
    Form Code
    Code:
    Private Sub Form_Load()
        LoadCombo Combo1
    End Sub

  4. #4
    Guest

    Smile Onya Serge

    Good call.

    Possible you could funk it up even more by passing another value indicating what data to load, thereby being able to load any combo box.


    LoadCombo Combo1, rs.FirstNames

    Public Sub LoadCombo(Combo1 as ComboBox, rsData as Variant)
    rs.movefirst
    Combo1.Clear
    Do
    Combo1.Additem rsData.fields(0)
    rsData.movenext
    if rsdata.eof then exit do
    loop
    combo1.ListIndex = 0

    Way Cool.....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width