Need help with combo box default selection

  • Thread starter Thread starter Nick D
  • Start date Start date
N

Nick D

I have a combo box that selects 1 of 7 different values.
I want to how to write the code so that I can have the
last selection made on that form saved so it can become
the default the next time I open the form. I have tried
this code and it doesn't seem to work:

Choose_MESD_Employee.DefaultValue = """" &
Me.Choose_MESD_Employee & """"
DoCmd.Save acForm, Me.Name

Thank you,

Nick
 
Nick,

Try putting the following in the AfterUpdate event of the Form but use the
name of your combo box...

Me!cboYourCombo.DefaultValue = Me!cboYourCombo.Value

Should work record to record though I am not sure if it will persist once
you close the form.

Gary Miller
 
It didn't work...I tried that one also before. I got to
the previous code to make it work for a string. I save
the value using:

ComboBox.DefaultValue =
"""" & Me.ComboBox & """"

DoCmd.Save acForm, Me.Name


but what i think happens is that Access write a blank
default over it when I reopen the form. It seems as
though I can't get around it with out some heavy coding.
Let me know if you think of something else.

Thanks for your help,

Nick
 
Very Interesting!!!

I did some playing around with a test form by opening it in
design, setting a control default that was previously blank,
testing the default. All is fine. Close the form using
acformsave after forcing a previous save with a docmd.save.
I reopened in design again tested for the default and got a
blank message box.

You are right. It seems to be ignoring the programmatic
default change.

May want to repost again as I am out of ideas on this one
unless it would be to try the same thing at the table level
with a blank on the form so the default would be carried
over to the form. Don't have the time to play with that at
the moment.

Gary
 
I think your only solution is to save the setting in either a table within
the database, or in the Windows registry. For just one ( or a few ) values,
the registry works quite well. Look up SaveSetting and GetSetting in Help.

--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
 
Adrian,

Great suggestion. If you can't fight it work around it. Save
it and pull it up when the form is loaded.

Gary Miller
 
Back
Top