Link to home
Start Free TrialLog in
Avatar of Larry Brister
Larry BristerFlag for United States of America

asked on

MS Access 2003 COmbobox and VBA - Selected Item

My attached code works fine...
But, I've been out of VBA for a while.

When I select an Item, I want to display both columns...not just the bound one.

How do I do that?

Dim cmd1 As New ADODB.Command
Dim rst1 As ADODB.Recordset
'Connect to db and run stored proc based on Client ID
cmd1.ActiveConnection = CurrentProject.Connection
cmd1.CommandType = adCmdStoredProc
cmd1.CommandText = "usp_MarketingVisitationsGet"
cmd1.Parameters("@ClientID") = Me.txtClientID.Value

'Set the recordset
Set rst1 = cmd1.Execute()

With Me.cmbVisits
    .RowSourceType = "Value List"
    .BoundColumn = 1
    .ColumnCount = 2
    .ColumnWidths = ".5in;1.5in"
    .ColumnHeads = False
End With

With rst1
    .MoveFirst
    Do Until .EOF
        cmbVisits.AddItem !id & ";" & !visitStatus
        .MoveNext
    Loop
End With

Open in new window

Avatar of JieJenn
JieJenn

Can you attach a sample database? Your code looks fine to me.

Perhaps expand your combo width to see what happens.
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Larry Brister

ASKER

Thanks