Make subform close if query returns 0 records (1 Viewer)

robina

Access Developer
Local time
Yesterday, 19:40
Joined
Feb 28, 2012
Messages
102

bob fitz

AWF VIP
Local time
Today, 03:40
Joined
May 23, 2011
Messages
4,731
Instead of closing, you could set the sub form's Visible property to False
 

robina

Access Developer
Local time
Yesterday, 19:40
Joined
Feb 28, 2012
Messages
102
bob,
I agree, that would be great. I tried but believe I had the wrong syntax to refer to the actual subform vs. a control. Can you tell me the code?
 

bob fitz

AWF VIP
Local time
Today, 03:40
Joined
May 23, 2011
Messages
4,731
Try:
Me.NameOfSubFormControl.Visible = False
You will need to substitute the name of the name of the control (the bit in red). Keep in mind that a Subform control's "Name" property is not always the same as the actual form name.
 

robina

Access Developer
Local time
Yesterday, 19:40
Joined
Feb 28, 2012
Messages
102
I appreciate the quick response. I need to make the entire subform invisible, not any certain control.
 

bob fitz

AWF VIP
Local time
Today, 03:40
Joined
May 23, 2011
Messages
4,731
I appreciate the quick response. I need to make the entire subform invisible, not any certain control.
Yes,I know, but the Subform is a control of the main form and has it's own properties, just as textbox is a control with it's properties.
 

robina

Access Developer
Local time
Yesterday, 19:40
Joined
Feb 28, 2012
Messages
102
Okay, I got it to work. this is what I have in the load event of the subform:
Code:
If Me.RecordsetClone.RecordCount = 0 Then
        Me.Visible = False
 

Users who are viewing this thread

Top Bottom