On 15 Dec 2005 18:03:54 -0800, ken wrote:
Hi,
I want to reset the default value of a combo box everytime someone
selects something from its list.
I have in the after update event combo.defaultvalue = combo.value.
Anyhow this works, as long as I don't close the form. Once I close it
the new defalut value does not get saved. Is there any way I could save
it to the properties of the combo box?
Thanks,
Using A2k.
You cannot save a change in a combo box property unless you change it
in Design View.
I would suggest you create a table with one field and one record.
Field Name NewDefault Set it's datatype to whatever the
datatype is of the combo box bound column.
Table Name tblDefault
to store whatever the last selected value is (in the Combo AfterUpdate
event)
' First change the default value for use while this form is still
open.
Me!ComboName.DefaultValue = Me!ComboName
' Then save the value to the table.
CurrentDb.Execute "Update tblDefault Set tblDefault.NewDefault = " &
Me.ComboName & ";",dbFailOnError
The above assumes the bound column is a Number datatype.
Then DLookUp that value when you next open the form (in the Form's
Load event):
Me!ComboName.DefaultValue = DLookUp("[NewDefault]","tblDefault")
You do know, I hope, that the DefaultValue will only come into play
for new records?
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail