Hiding subform on open (1 Viewer)

Design by Sue

Registered User.
Local time
Yesterday, 17:06
Joined
Jul 16, 2010
Messages
654
I need to hide my subform on load or open of the main form but am experiencing some weird results. I have tried putting Me.SubForm.Form.Visible = False in both the on open and the on load of the main form and it works only if the tables on which the subform have records in them. If the tables for the subforms are empty I get an error 2467 telling me that "The expression you entered refers to an object that is closed or doesn't exist." I find this strange because from all I can find the subform loads first.

How can I hide the subform when the main form opens no matter what records exist or don't??

Sue
 

Frothingslosh

Premier Pale Stale Ale
Local time
Yesterday, 20:06
Joined
Oct 17, 2012
Messages
3,276
You could try setting the subform to not have a control source at first, and only insert one once the user does something. That should allow you to default the subform to invisible.
 

Design by Sue

Registered User.
Local time
Yesterday, 17:06
Joined
Jul 16, 2010
Messages
654
Thanks - actually it was Record Source - strange thing is I did have this correct but somehow the record source became part of the properties list and that was what was causing the problem. I must have been working in code and close the form before while the record source was entered and then it just stayed there (I have had this happen before) Thanks so much for pointing me in the correct directly.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 01:06
Joined
Feb 19, 2013
Messages
16,635
this

Me.SubForm.Form.Visible = False

should be this

Me.SubForm.Visible = False
 

Design by Sue

Registered User.
Local time
Yesterday, 17:06
Joined
Jul 16, 2010
Messages
654
I have it as shown and it is working - what is the difference between the two?
Sue
 

CJ_London

Super Moderator
Staff member
Local time
Today, 01:06
Joined
Feb 19, 2013
Messages
16,635
actually nothing so far as I can see! I've just never done it that way.:D
 

Users who are viewing this thread

Top Bottom