subform visible/invisible based on control (1 Viewer)

kellygirl

New member
Local time
Today, 10:55
Joined
Jun 18, 2015
Messages
8
Hi,

Yup, I'm new here. And I'm an experienced Access user, however only an "advanced beginner" in vba.

Right now I need to have a subform that shows up smack dab in the middle of my main screen when visible - which is what I want - but only based on a specific value of a control on the main form. Specifically, if a control's value is "See Spreadsheet", I want the subform visible front and center as it contains the link to the server location for that specific record. If the control's value is not "See Spreadsheet", I want the form to be invisible.

My code:

If Me.BudgetsFacultyAccountNumber = "SEE SPREADSHEET" Then

Me.frmMsgBoxUpdateSpreadsheet.Form.Visible = True
Me.BudgetsFacultyServerLocation.Visible = True
Else:
Me.frmMsgBoxUpdateSpreadsheet.Form.Visible = False
Me.BudgetsFacultyServerLocation.Visible = False

End If

The red lines result in an MS VBA error: "Compile error: Method or data member not found."

I've tried referencing that subform a hundred different ways, but I can't get it to work.

Any idea what I'm doing wrong?

Thanks!
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 07:55
Joined
Aug 30, 2003
Messages
36,126
Try referring to the subform control

Me.frmMsgBoxUpdateSpreadsheet.Visible = True
 

kellygirl

New member
Local time
Today, 10:55
Joined
Jun 18, 2015
Messages
8
That was one of the hundred other ways I tried. But I tried it again, just to be sure - and I still get the same answer.

BTW - I am running this from the main form's "On_Current" event. And I'm using Access 2013.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 07:55
Joined
Aug 30, 2003
Messages
36,126
Are you sure that's the name of the subform control, rather than the subform itself, if different? I just tested and this worked fine:

Me.SubformControlName.Visible = False
 

MSAccessRookie

AWF VIP
Local time
Today, 10:55
Joined
May 2, 2008
Messages
3,428
frmMsgBoxUpdateSpreadsheet is an expected name for a Form or Sub-Form in Access. Is it also the name of the Control on your Main Form that contains the Sub-Form?

If so, then what pbaldy said should work for you. If not, then if you change frmMsgBoxUpdateSpreadsheet to the proper Subform Control Name, and try again.

-- Rookie

Note: Once again I get there just a little too slow
 
Last edited:

kellygirl

New member
Local time
Today, 10:55
Joined
Jun 18, 2015
Messages
8
Woo hoo!

Control name was not the form name! Changed the reference to UPDATE SPREADSHEET and it works!

THANKS! MSAccessRookie

:)
 

Users who are viewing this thread

Top Bottom