subform visible/invisible based on control

kellygirl

New member
Local time
Today, 09:51
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!
 
Try referring to the subform control

Me.frmMsgBoxUpdateSpreadsheet.Visible = True
 
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.
 
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
 
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:
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

Back
Top Bottom