hansretallick
Technical User
I have some controls on a form open that are shown or hidden depending on whether or not there is data accessed by queries. I have decided to default to the controls being visible on form open, and if the query results in no data, the controls are then hidden. For some reason the controls are visible whether there is data or not. Can anyone show me what I am doing wrong? Here is an example of the code I am using in the OnOpen property of the form.
'Run Pay Landlord controls
DoCmd.OpenQuery "qryStatementDue1", acViewNormal, acEdit
If Query!qryStatementDue1.RecordsetClone.RecordCount = 0 Then
Me.ImgPayLandlords.Visible = False
Me.lblPayLandlords.Visible = False
End If
I run this three times for three controls based on three different queries. All of the controls are visible whether there is data or not.
I have tried
If Me.RecordsetClone.RecordCount = 0 Then
but that doesn't work either.
'Run Pay Landlord controls
DoCmd.OpenQuery "qryStatementDue1", acViewNormal, acEdit
If Query!qryStatementDue1.RecordsetClone.RecordCount = 0 Then
Me.ImgPayLandlords.Visible = False
Me.lblPayLandlords.Visible = False
End If
I run this three times for three controls based on three different queries. All of the controls are visible whether there is data or not.
I have tried
If Me.RecordsetClone.RecordCount = 0 Then
but that doesn't work either.