Dependent subform?

  • Thread starter Thread starter Gabe
  • Start date Start date
G

Gabe

I'm trying to have a subform appear on my main form if a certain value is
selected from a combobox, but I'm having some trouble. I put the following
code in the AfterUpdate field of my combobox but it doesn't work?

Private Sub ServiceTypeSEIU_AfterUpdate(Cancel As Integer)
If Me.ServiceType = "SEIU" Then
Me.SEIU_Only_Query.Form
.Enabled = True
.Visible = True
Else: Me.SEIU_Only_Query.Form
.Enabled = False
.Visable = False
End If
End Sub

Can someone please help?

Thanks,
~Gabe
 
You shouldn't need to enable/disable a subform if you are making it
Visible/Hidden. Is SEIU_Only_Query the actual name of the subform control,
or the subform? You need the name of the control, and you need to leave off
the .Form. Your code should look like:

Private Sub ServiceTypeSEIU_AfterUpdate(Cancel As Integer)
If Me.ServiceType = "SEIU" Then
Me.SEIU_Only_Query.Visible = True
Else
Me.SEIU_Only_Query.Visible = False
End If
End Sub
 
"having some trouble" doesn't give us much to go on ...

(by the way, if you haven't told Access to use an object, it doesn't know
what you are referring to. I usually use the "With" command...)

(by the way, two ... your code appears to be for a control named
"ServiceTypeSEIU", but you test for "ServiceType" = "SEIU". )

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Back
Top