I have a report where in two places (43a and 43b) I need to insert one of three subreports, depending on who is paying. I used the following code in the Current event:
Private Sub Report_Current( )
If Queries.qry_LOI .[Who_pays] = "B" Then
Set Me.[subrpt_43a_Both Pay].Visible = True:
Set Me.[subrpt_43a_Pilg rimPays].Visible = False:
Set Me.[subrpt_43a_Spon sorPays].Visible = False:
Set Me.[subrpt_43b_Both Pay].Visible = True:
Set Me.[subrpt_43b_Pilg rimPays].Visible = False:
Set Me.[subrpt_43b_Spon sorPays].Visible = False
ElseIf Queries.qry_LOI .[Who_pays] = "S" Then
Set Me.[subrpt_43a_Both Pay].Visible = False:
Set Me.[subrpt_43a_Pilg rimPays].Visible = False:
Set Me.[subrpt_43a_Spon sorPays].Visible = True:
Set Me.[subrpt_43b_Both Pay].Visible = False:
Set Me.[subrpt_43b_Pilg rimPays].Visible = False:
Set Me.[subrpt_43b_Spon sorPays].Visible = True
Else
Set Me.[subrpt_43a_Both Pay].Visible = False:
Set Me.[subrpt_43a_Pilg rimPays].Visible = True:
Set Me.[subrpt_43a_Spon sorPays].Visible = False:
Set Me.[subrpt_43b_Both Pay].Visible = False:
Set Me.[subrpt_43b_Pilg rimPays].Visible = True:
Set Me.[subrpt_43b_Spon sorPays].Visible = False
End If
End Sub
However it doesn't work. If I scroll down in report view the subreports all stay visible, but if I page down I get a VBA compile error on the word "Visible", saying "Invalid use of property".
Can anyone see what I'm doing wrong?
Private Sub Report_Current( )
If Queries.qry_LOI .[Who_pays] = "B" Then
Set Me.[subrpt_43a_Both Pay].Visible = True:
Set Me.[subrpt_43a_Pilg rimPays].Visible = False:
Set Me.[subrpt_43a_Spon sorPays].Visible = False:
Set Me.[subrpt_43b_Both Pay].Visible = True:
Set Me.[subrpt_43b_Pilg rimPays].Visible = False:
Set Me.[subrpt_43b_Spon sorPays].Visible = False
ElseIf Queries.qry_LOI .[Who_pays] = "S" Then
Set Me.[subrpt_43a_Both Pay].Visible = False:
Set Me.[subrpt_43a_Pilg rimPays].Visible = False:
Set Me.[subrpt_43a_Spon sorPays].Visible = True:
Set Me.[subrpt_43b_Both Pay].Visible = False:
Set Me.[subrpt_43b_Pilg rimPays].Visible = False:
Set Me.[subrpt_43b_Spon sorPays].Visible = True
Else
Set Me.[subrpt_43a_Both Pay].Visible = False:
Set Me.[subrpt_43a_Pilg rimPays].Visible = True:
Set Me.[subrpt_43a_Spon sorPays].Visible = False:
Set Me.[subrpt_43b_Both Pay].Visible = False:
Set Me.[subrpt_43b_Pilg rimPays].Visible = True:
Set Me.[subrpt_43b_Spon sorPays].Visible = False
End If
End Sub
However it doesn't work. If I scroll down in report view the subreports all stay visible, but if I page down I get a VBA compile error on the word "Visible", saying "Invalid use of property".
Can anyone see what I'm doing wrong?
Comment