?
Solved

MS Access 2003 COmbobox and VBA - Selected Item

Posted on 2012-12-24
3
Medium Priority
?
947 Views
Last Modified: 2012-12-24
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

0
Comment
Question by:lrbrister
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Expert Comment

by:JieJenn
ID: 38719055
Can you attach a sample database? Your code looks fine to me.

Perhaps expand your combo width to see what happens.
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 2000 total points
ID: 38719081
"I want to display both columns..."
Do you mean after the selection?
You cannot do that - unless you create a concatenated column.

mx
0
 

Author Closing Comment

by:lrbrister
ID: 38719137
Thanks
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question