Setting default value

C

cinnie

hi to all

I have an option group (ogpMode) that contains two radio buttons (A, having
option value 1, and B, having option value 2). The default value for the
option group is initially set at 1.

I'd like the option group's default value to be whatever I last changed it
to. If I pick B, for example, then I'd like B to be selected next time I use
the program.

Why doesn't this work in the option group's AfterUpdate event?

Me!opgMode.DefautValue = Me!opgMode

thanks
 
J

Jeanette Cunningham

Cinnie,
You will need to store the value of the option group somewhere - perhaps in
a table.
If you stored the value on a hidden form, you could easily get the value to
use next time, until you close the database.
Each time the value of the option group changes from its previous value, use
its after update event to store the new value in the table.
Each time you open the form, retrieve the default value from the table and
set the default value for the option group.
Bound text boxes and some other controls do have a default value when you
open a form to an existing record.

Jeanette Cunningham
 
F

fredg

Cinnie,
You will need to store the value of the option group somewhere - perhaps in
a table.
If you stored the value on a hidden form, you could easily get the value to
use next time, until you close the database.
Each time the value of the option group changes from its previous value, use
its after update event to store the new value in the table.
Each time you open the form, retrieve the default value from the table and
set the default value for the option group.
Bound text boxes and some other controls do have a default value when you
open a form to an existing record.

Jeanette Cunningham

Code the optionGroup's AfterUpdate event:

Me.OptionGroupName.DefaultValue = Me.OptionGroupName

This will set the default value for new records to whatever the last
entered value was. It does NOT retain the new value once the database
is closed.
 
L

Linq Adams via AccessMonster.com

Code the optionGroup's AfterUpdate event:
Me.OptionGroupName.DefaultValue = Me.OptionGroupName

That's what the OP already tried! I tried it also and it works perfectly for
me. Other than the ever possible corruption, the only other things I can
think of are a misspelling of the frame's name (the option group name) or an
accidental placing of the code in the AfterUpdate event of one of the Radio
Butttons rather than in the frame's AfterUpdate event.
 

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