Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / January 2007

Tip: Looking for answers? Try searching our database.

selecting a combo box item programatically

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Anja - 29 Jan 2007 20:44 GMT
Hey everyone,

I have a drop down combo box that gets its data from a query. It has
an ID field which is also the value field (and is hidden) and first
and last name fields.

So, the query looks like:

SELECT Persons_T.ID, Persons_T.[First Name], Persons_T.[Last Name]
FROM Persons_T ORDER BY [Last Name];

So, what I am trying to do is select an item programatically using
VBA. So, I get an ID and based on this ID value, I want to select the
value in the combo field.

I tried something like:

MyCombo.Value = ID. However, that does not seem to work. Do I have to
loop over all the combo list values and compare the Value field and
then set the selected value or is there a better way to do it?

Thanks for any help you might be able t give me.

Best,
Anja
Perry - 29 Jan 2007 22:22 GMT
Statements like below lines of code should work.
You can select a value and pass this to a combo without problems, provided
the passed value coïncides with a boundcolumn value of yr combo.

Dim ID As Long
ID = 38
Me!MyCombo = ID
(assuming 38 is a valid ID in the target table/recordsource of the form)

If this isn't working, there's something else bugging you.
In such case, repost more surrounding info and specify what you want achieve
Info on which Access version would be convenient as well.

Krgrds,
Perry

> Hey everyone,
>
[quoted text clipped - 21 lines]
> Best,
> Anja
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.