ColumnHeader of ComboBox?

Posted on 2003-02-20
Medium Priority
Last Modified: 2008-03-06
How do I get in code the ColumnHeader of a specific Column of a ComboBox?
(The combox Box is on a form..Not created in code)
Question by:tbsgadi
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
1 Comment
LVL 41

Accepted Solution

shanesuebsahakarn earned 400 total points
ID: 7986448
You could use something like this:

Dim rst As DAO.Recordset
Dim fld As Field

Set rst = CurrentDb.OpenRecordset(Me!Combo1.RowSource)
For Each fld In rst.Fields
   MsgBox fld.Name
Set rst = Nothing

This retrieves the field names of the query on which the combo is based, but does not take into account hidden columns in the combo.

You could put it into a function (warning, this is air code!):

Function GetColHead(ComboName as String, ColNum As Long) As String
Dim rst As DAO.Recordset

Set rst = CurrentDb.OpenRecordset(Me(ComboName).RowSource)
GetColHead = rst(ColNum).Name
Set rst = Nothing
End Function

Put the function into the form, and call it with something like:

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

765 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