A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Change displayed combo box value using VBA



 
 
Thread Tools Display Modes
  #1  
Old April 30th, 2009, 02:48 PM posted to microsoft.public.access
Larry Kahm
external usenet poster
 
Posts: 148
Default Change displayed combo box value using VBA

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



  #2  
Old April 30th, 2009, 03:38 PM posted to microsoft.public.access
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default Change displayed combo box value using VBA

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


"Larry Kahm" wrote in message
...
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





  #3  
Old April 30th, 2009, 09:21 PM posted to microsoft.public.access
Larry Kahm
external usenet poster
 
Posts: 148
Default Change displayed combo box value using VBA

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

"Jeff Boyce" wrote in message
...
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


"Larry Kahm" wrote in message
...
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







  #4  
Old April 30th, 2009, 10:15 PM posted to microsoft.public.access
Larry Kahm
external usenet poster
 
Posts: 148
Default Change displayed combo box value using VBA

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

"Larry Kahm" wrote in message
...
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

"Jeff Boyce" wrote in message
...
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


"Larry Kahm" wrote in message
...
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









  #5  
Old April 30th, 2009, 10:16 PM posted to microsoft.public.access
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default Change displayed combo box value using VBA

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


"Larry Kahm" wrote in message
...
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

"Jeff Boyce" wrote in message
...
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


"Larry Kahm" wrote in message
...
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









 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:04 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.