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.

Set a combo box to an entry and clear it of everything

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
XP - 28 Jan 2007 15:36 GMT
Using Office 2003 and Windows XP; using VBA, how can I:

1) Programmatically set a combo box to a particular entry in the drop down
list?

2) Clear the combo box drop down list of all entries?

If possible, please post generic VBA example code.

Thanks a lot in advance.
Rick Brandt - 28 Jan 2007 15:50 GMT
> Using Office 2003 and Windows XP; using VBA, how can I:
>
> 1) Programmatically set a combo box to a particular entry in the drop down
> list?

Me!ComboBoxName = SomeValue

SomeValue would need quotes around it if it was a Text value.

> 2) Clear the combo box drop down list of all entries?

Don't understand what you mean by "entries".  A ComboBox can have only one
"selection" so I must assume you want all of the choices in the list removed?
In that case just set the RowSource property to "".

Me!ComboBoxName.RowSource = ""

Signature

Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt   at   Hunter   dot   com

XP - 28 Jan 2007 16:42 GMT
Hi and thanks Rick.

When I run this code from a standard code module:

Forms(gcsFormMainMenu).Controls("cboMainDept1") = 0

It sets the value of the drop down to zero rather than the first item in the
drop down list. How can I make that work?

Thanks again.

> > Using Office 2003 and Windows XP; using VBA, how can I:
> >
[quoted text clipped - 12 lines]
>
> Me!ComboBoxName.RowSource = ""
Rick Brandt - 28 Jan 2007 16:52 GMT
> Hi and thanks Rick.
>
[quoted text clipped - 4 lines]
> It sets the value of the drop down to zero rather than the first item in the
> drop down list. How can I make that work?

Well, that is not what you asked for :-)

If the bound column of the ComboBox is the first one...

Forms(gcsFormMainMenu).Controls("cboMainDept1") =
Forms(gcsFormMainMenu).Controls("cboMainDept1").Column(0,0)

If the bound column is not the first column then the first zero would be changed
to 1 for the second column, 2 for the third, etc..  The second zero would not be
changed as that specifies the first row.

Signature

Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt   at   Hunter   dot   com

XP - 28 Jan 2007 17:16 GMT
> > Hi and thanks Rick.
> >
[quoted text clipped - 6 lines]
>
> Well, that is not what you asked for :-)

YEAH, I know; things changed as I was developing. This is sort of a follow
up...

> If the bound column of the ComboBox is the first one...
>
[quoted text clipped - 4 lines]
> to 1 for the second column, 2 for the third, etc..  The second zero would not be
> changed as that specifies the first row.

WORKS great thanks!
 
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.