Set cbo selection NOT to change when form opens?

G

Guest

I have this code in my subform Me.InsuranceConsultant.Value =
Me.InsuranceConsultant.ItemData(2).

It sets the 3rd selection in my cbo box as the default. This works fine but
if a user wants and selects a different selection from the cbo it changes it
back to pending everytime the form opens.
How do I set it so it does not change the record unles the user wants it
changed?

Thanks
 
D

Douglas J. Steele

It sounds as though the combo box is bound to the field in the table. If
that's the case, then changing the selection will update the table.

You could put code into the form's BeforeUpdate event to check whether they
do want the change made, and set the event's Cancel = True if they don't.
 
G

Guest

You stated "then changing the selection will update the table." I have that
little piece of code in the on load event. However everytime the form opens
it changes it back (even if the user selects something different) to the
default. How do I get the correct (the selection the user selected) to stay
once it has been selected from the cbo?

Thanks gain
 
D

Douglas J. Steele

Is the control bound or not? Look at the properties of the text box on the
form. Does the ControlSource property have a value?
 
G

George Nicholson

in the Form_Current event:

If Me.NewRecord Then
'Your code that sets the combo box
End If

This will "pre-select" the specified value in your combo *for new records
only*.
It will not change any existing records.

Remove the code from the Load event or wherever u have it now.

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top