Combo Box

twosides

Registered User.
Local time
Today, 09:56
Joined
Jul 19, 2005
Messages
38
I use a combo box to select and enter data into a field. I feel sure there is a way to get the combo box to 'remember, what the last selected value was and get it preselected or populated when you create a new record.
Would this be also possible if there were say three combo boxes on the form?
Could they all be pre populated?
Cheers
 
With an unbound combobox, this would be the normal behavior; unbound controls, whether a combobox or a textbox, retain the last value they held when moving to another record. For a bound combobox, you'd use one of the following syntax, depending on the Datatype of the data held in the combobox:

For Text:
Code:
Private Sub YourCombo_AfterUpdate()
  Me.YourCombo.DefaultValue = """" & Me.YourCombo & """"
End Sub

For Numeric:
Code:
Private Sub YourCombo_AfterUpdate()
  Me.YourCombo.DefaultValue = Me.YourCombo 
End Sub

For Dates:
Code:
Private Sub YourCombo_AfterUpdate()
  Me.YourCombo.DefaultValue = "#" & Me.YourCombo & "#"
End Sub

You can do this for as many comboboxes (and textboxes, as well) as you'd like on a form.
 
Great I will try it later
Thanx
 
Fantastic. Job done.
This does what I want.
I want to improve the functionality a bit. When I open the database initially there are no values stored and thus displayed in the combo boxes which I can cope with and is preferable I have to say.
I have made a popup form which is basically two command buttons - Yes and No. The dialog asks if you wish to use the previous combo box values from the last form entered. This popup is activated when I click a new record command button. But i would like to surpress this when the database or data entry form is initially opened due to the fact that there is no values stored initially in the combo boxes.
Is there a way of testing if there are values stored? Or a similar way of doing it?
Cheers
 
if me.combo1.defaultvalue="" then
else
Your Current code here
endif
 

Users who are viewing this thread

Back
Top Bottom