populate combobox with default values (1 Viewer)

abenitez77

Registered User.
Local time
Today, 04:04
Joined
Apr 29, 2010
Messages
141
I saved the values of 3 comboboxes to a table and when the form opens, I want those values (default) to be populated in the comboboxes. I tried doing it like this below...but I get a run-time error 424 (object required).

Me.cmb_Projects.Column(1) = rs!DefProject
Me.cmb_Projects.Column(0) = rs!DefProjectid
Me.cmb_Periods.Column(1) = rs!DefPeriod
Me.cmb_Periods.Column(0) = rs!DefPeriodid
Me.cmb_Options = rs!DefOptions
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 09:04
Joined
Jul 9, 2003
Messages
16,280
Try:-
Me.cmb_Projects.DefaultValue = rs!DefProjectid
 

Cronk

Registered User.
Local time
Today, 18:04
Joined
Jul 4, 2013
Messages
2,772
Me.cmb_Projects = rs!DefProjectid
Me.cmb_Periods = rs!DefPeriodid
Me.cmb_Options = rs!DefOptions
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 16:04
Joined
May 7, 2009
Messages
19,233
Code:
Private Sub Form_Load()
    Dim i As Integer
    '
    ' your code that opens the recordset somewhere here
    ' ...
    ' ...
    ' ...
    With Me.cmb_Projects
        For i = 0 To .ListCount - 1
            If .Column(0, i) = rs!DefProjectID And .Column(1, i) = rs!DefProject Then
                .value = .ItemData(i)
                Exit For
            End If
        Next
    End With
    With Me.cmb_Periods
        For i = 0 To .ListCount - 1
            If .Column(0, i) = rs!DePeriodID And .Column(1, i) = rs!DefPeriod Then
                .value = .ItemData(i)
                Exit For
            End If
        Next
    End With
    Me.cmb_Options = rs!DefOptions
End Sub
 

Users who are viewing this thread

Top Bottom