Set combo box default value

S

Sajit

I am trying to set the default value of a combo box to the last value with
which the form was closed with.

I was expecting this setting in the 'on form close' to work much the same
way it would if I were to enter the default value in the properties manually.

Private Sub Form_Close()
Forms![list of standards]![Text25].DefaultValue = """" & Forms![list of
standards]!Text25 & """"
Debug.Print Me.Text25.DefaultValue

End Sub

But it does not.

Why does the setting that I do, don't stick in there?

Sajit
Abu Dhabi
 
J

Jeff Boyce

Sajit

I'm wondering if the "Close" event of the form is really where you want this
to happen. There's a chance that this gets triggered too late...

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
S

Sajit

Jeff, Dave,

With the DoCmd I should see the last value set in the default value
properties, provided I close it through a close button that I would have to
create. Perhaps I have to also remove the red x button from the user.

I have done the 'on close' event for forms in VB6 and it does work by the
red x or the close button that I had put in. Is there a work around for it in
VBA for the event getting triggered for the red x 'close'.

Sajit

Jeff Boyce said:
Sajit

I'm wondering if the "Close" event of the form is really where you want this
to happen. There's a chance that this gets triggered too late...

Regards

Jeff Boyce
Microsoft Office/Access MVP

Sajit said:
I am trying to set the default value of a combo box to the last value with
which the form was closed with.

I was expecting this setting in the 'on form close' to work much the same
way it would if I were to enter the default value in the properties
manually.

Private Sub Form_Close()
Forms![list of standards]![Text25].DefaultValue = """" & Forms![list of
standards]!Text25 & """"
Debug.Print Me.Text25.DefaultValue

End Sub

But it does not.

Why does the setting that I do, don't stick in there?

Sajit
Abu Dhabi
 
Top