Toggle between forms using Option Group

G

Guest

Does anyone know how to toggle between a form and a subform using the Option
Group. I have a form, wherein when you select the option button "A" it
enables a control source on the subform to become active, and if you select
the other option "B" button a control source on the main form becomes active
and "A" becomes inactive. Thanks!
 
J

John Vinson

Does anyone know how to toggle between a form and a subform using the Option
Group. I have a form, wherein when you select the option button "A" it
enables a control source on the subform to become active, and if you select
the other option "B" button a control source on the main form becomes active
and "A" becomes inactive. Thanks!


Could you explain what you mean by "a control source on the subform"
and "a control source on the mainform"??? A control source is merely a
property of a control, namely the field to which that control is
bound. A Subform doesn't have a Control Source - it has a
Recordsource, and presumably multiple controls, each with its own
Control Source. And (unless you've set its Enabled property to false)
all controls are already "active".

Could you clarify just what you're trying to accomplish?

John W. Vinson[MVP]
 
G

Guest

John, that is correct the items in the subform are inactive and if the user
selects the option it would become active.
 
G

Guest

John, this is what I am trying to do, I have a form (me.form) which has has
an option goup (Option 138), if the user selects "A" in the option group then
the text box in the subform will become unlocked...(the defalt is locked).
However, if the user selects "B" the text box on the form become
unlocked....again the default is locked. I really appreciate your help.
 
J

John Vinson

John, this is what I am trying to do, I have a form (me.form) which has has
an option goup (Option 138), if the user selects "A" in the option group then
the text box in the subform will become unlocked...(the defalt is locked).
However, if the user selects "B" the text box on the form become
unlocked....again the default is locked. I really appreciate your help.

You don't give any indication of the names of these controls, but...

Use the AfterUpdate event of the Option Group. Remember that an Option
Groups value is a number, the number assigned to the checkbox or
button within the option group. Something like

Private Sub optMyOptionGroup_AfterUpdate()
Select Case optMyOptiongroup
Case 1 ' user selected A, if that is assigned 1
Me!subMySubform.Form!txtMyTextbox.Locked = False
Case 2
Me!txtMainTextbox.Locked = False
End Select
End Sub

You may also want to set both controls to Locked in the form's Current
event, to reset it when you move to a new record.

John W. Vinson[MVP]
 
G

Guest

John, it doesn't seem to work. Maybe it'll help if I gave you the textbox
names. The text box in the subform is "repcode" and the text box in the main
form is "entername"
 
J

John Vinson

John, it doesn't seem to work. Maybe it'll help if I gave you the textbox
names. The text box in the subform is "repcode" and the text box in the main
form is "entername"

Then replace subMySubform with the Name property of your subform
control; replace txtMyTextbox with repcode; and replace txtMainTextbox
with entername.


John W. Vinson[MVP]
 
G

Guest

Does this look right to you? "catsub1" is the subform and the name of the
parent form is "category1"

Me!catsub1.Form!repcode.Locked = False
 
J

John Vinson

Does this look right to you? "catsub1" is the subform and the name of the
parent form is "category1"

Me!catsub1.Form!repcode.Locked = False

Be sure to distinguish the name of the Subform Control (the empty box
on the mainform which contains the subform) and the name of the form
object within that control. It's the former that is needed in this
syntax - the name of the form itself is irrelevant.

This can be confusing because Access defaults to giving the Subform
Control the same name as the Form... but they need not be the same.

I presume you ask because something isn't working???

John W. Vinson[MVP]
 
G

Guest

I keep getting that debug error message, I even renamed the subform so that
it is intentionally different from the name of the form itself.

Me!catsub100!Form.repcode.Enabled = False

And it just does not work....any ideas John??
 
J

John Vinson

Me!catsub100!Form.repcode.Enabled = False

Should be

Me!catsub100.Form!repcode.Enabled = False

Note the period before Form - you're looking at the Form Property of
an object, rather than some member of a collection. Sorry, my typo
originally!

The ! after Form could probably be either ! or .

John W. Vinson[MVP]
 
G

Guest

John, I understand it now and I really appreciate your help and the help that
you provide to everyone in this forum, Thank You!....the solution was

Me.catsub100.Form.[Rep Code].Enabled = True
 
J

John Vinson

John, I understand it now and I really appreciate your help and the help that
you provide to everyone in this forum, Thank You!....the solution was

Me.catsub100.Form.[Rep Code].Enabled = True

Yep. "Rep Code" and "repcode" are two different strings, totally
unrelated to a computer. That's one good reason not to use blanks in
field or control names!

Glad I was able to help.

John W. Vinson[MVP]
 

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