Reset a combobox to its default value

rgsmpx

New member
Local time
Today, 20:54
Joined
Oct 8, 2001
Messages
6
Access is slowly beating me down with its virtually useless help information, and I find it very difficult to get the answers through the MS knowledge database. Fortunately, this forum has been quite helpful in overcoming my access frustrations!

Enough editorializing. Here is my basic problem that I hope is very simple to solve

I have a form set up with various unbound combo boxes that enable the user to filter the records that display. I also have a command button, "Show all records" that removes the filter and displays all the records. However, I would also like the combo boxes to reset to their default values when the user clicks the "Show all records" button.

The default values on the combo boxes are all set to various ItemData values, usually 0,1, or 2. For example, the default value for the cboSelectLeadSource combo box is [cboSelectLeadSource].[ItemData](0).

What code do I use to get the comboboxes to display the default values when the user clicks the "Show all Records" button? I tried

Me!cboSelectLeadSource = Me!cboSelectLeadSource.defaultvalue

but that populates the combo box with "[cboSelectLeadSource].[ItemData](0)" rather than the actual first item in the list (in this case, "All").

Please help!

Thanks,
RG
 
By fiddling around I found a solution, but it seems convoluted. Is there a better?

Me!cboSelectLeadSource = [cboSelectLeadSource].[ItemData](Left(Right(Me!cboSelectLeadSource.DefaultValue, 2), 1))
 

Users who are viewing this thread

Back
Top Bottom