Change displayed combo box value using VBA

L

Larry Kahm

I have a Contacts form that contains, among other fields, a combo box for
Company name and a check box for Currently employed; the latter is set to
true when a new contact record is added to the database.

When the record is updated, and the person no longer works for the company,
the check box is unchecked.

At that point, I'd like to set the value in the Company name combo box to
"(None)" - without the quotes. (None) is a valid company record.

I have tried using:

Me.cboCompanyID = 129
Me.cboCompanyID.Refresh

But I don't think this is doing what I want it to. In any case, the value
in the combo box does not get displayed in the record.

What simple facet of combo box behavior am I missing here?

Thanks!

Larry
 
J

Jeff Boyce

Larry

"How" depends on "what".

What row source do you have feeding the combobox?

What column is bound? ... is visible?

What is the underlying table data type ... are you using a lookup data type,
that displays one thing but stores another?

(also, I understand that some combobox problems have crept in related to
service pack updates -- have you searched on-line for those issues?)

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
L

Larry Kahm

Jeff,

The rowssource is a query that pulls in two fields: CompanyID and
CompanyName (sorted)

The ID is bound and not visible; the company name is shown on the list and
the ID is stored in the database.

Thanks!

Larry
 
L

Larry Kahm

And sometimes, just sometimes, I get lost in the silliness that surrounds
this project and lose track of the obvious.

In this case, I want the value "(None)" to display when the contact is no
longer employed.

I have the list sorted alphabetically (prior post) - so this value is the
first one on the list.

Lo and behold, if I code:

!cboCompanyID.Value = !cboCompanyID.Column(0, 0)

I get exactly what I want.

Sheesh!

Larry
 
J

Jeff Boyce

I don't know if this will make a difference in your environment (you don't
mention which version of Access), but I've found that objects that I create
are referred to with fewer problems if I use the 'bang' (!) instead of the
'dot' (.) ...

Try:

Me!cboCompanyID = 129

And do a search on combobox problems associated with service packs...

Regards

Jeff Boyce
Microsoft Office/Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top