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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|