Make subform visible based on case

  • Thread starter Thread starter Sandra Grawunder
  • Start date Start date
S

Sandra Grawunder

I have a main form frmRegistration with 2 subforms,
frmVisitorTitle and frmGuestTitle. I would like the
subforms to be visible only under certain conditions. I
have a radio button option group with 3 choices:
Delegate (value = 1)
Guest (value = 2)
Visitor (value = 3)

The value of this option group is stored in the field
RType. Here's what I am trying to do:

If RType is 1 (Delegate) don't show the subforms.
If RType is 2 (Guest) show frmGuestTitle only.
If Rtype is 3 (Visitor) show frmVisitorTitle only.

Here is the event proc I started, but it doesn't work:

Private Sub RType_AfterUpdate()

Select Case Me.RType.Value

Case 1
Me.frmVisitorTitle.Visible = False
Me.frmGuestTitle.Visible = False
Case 2
Me.frmVisitorTitle.Visible = False
Me.frmGuestTitle.Visible = True
Case 3
Me.frmVisitorTitle.Visible = True
Me.frmGuestTitle.Visible = False
End Select

End Sub

I have written case statements before that worked but
they were based on string values from fields. Is this my
problem because the value obtained from the option group
is numeric?

Thanks for your help,

Sandra G
 
Sandra,

Your code is correct. I replicated the situation, and it worked
flaulessly. The first possibility that comes to mind as to why it
doesn't work for you, is that the option group is not returning what you
think it does. Try inserting a
Debug.Print Me.RType
before the Select Case, so you can see in the immediate window what it
actually returns.
What vtype is field RType in the table? Any cahnce it is text? If that's
the case, then you will need to modify your Case statements accordingly.

HTH,
Nikos
 
Well, I must have the data type or something else wrong.
Thank you for the suggestion!
Sandra G
 
Back
Top