Link to home
Start Free TrialLog in
Avatar of jwandmrsquared
jwandmrsquared

asked on

Set default value of Combo box using displayed combo box value

I am attempting to allow a user to reset the default value of a combo box based on its displayed value.  I have 4 combo boxes of differing types to do this with (one integer, 3 text).  For example, I want the user to be able to reset a default year on their own, and a combo box with available years is already displayed.  Functionally, I want the user to select a year, push a "set to default" button which will then reset that users default value to the displayed value.  Each user has their own "front-end" copy of access (everything except tables - which are linked), so this should be easy but I'm stumped.  Here is what I attached to the "set to default" button:

Private Sub set_default_yr_Click()

Dim reset_yr As Integer

Me.CurYear.Requery
reset_yr = Me.CurYear.Value
Me.CurYear.DefaultValue = reset_yr
Me.CurYear.Requery



End Sub

Oddly, my immediate window shows a null value for reset_yr after I push the set to default button.  Thanks for your help!
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Give this a try:

Private Sub set_default_yr_Click()

Dim reset_yr As Integer

Me.refresh
reset_yr = Me.CurYear.Value
Me.CurYear.DefaultValue = reset_yr
Me.CurYear.Requery

End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Gozreh
Gozreh
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jwandmrsquared
jwandmrsquared

ASKER

Not what I wanted to hear but at least it prevents hours of searching.