Accessing button on subform ...

andrefrancis

andrefrancis
Local time
Today, 10:07
Joined
Mar 11, 2005
Messages
40
... why oh why is it so difficult!

I have tried lots of different combinations and I am currently tearing my hair out with frustration.

My button is butBackCtlPnl03; my subform is frmSessions; the control is Sessions and my current code (on main Form Load) is:

Me.Sessions.frmSessions.butBackCtlPnl03.Visible = False

but Access gives me a Compile error: Method or data member not found and highlights 'frmSessions'.

Can anyone help?
 
Try...

Me!frmSessions.Form!butBackCtlPnl03.Visible = False
 
Meltdown said:
Try...

Me!frmSessions.Form!butBackCtlPnl03.Visible = False

I tried it and I get error 2465: can't find the field 'frmSessions'
 
It can only be that the controls are not named correctly, as the syntax I supplied is correct for what you want to do.

Does setting...Me!frmSessions.visible = False ....in the onload event of the main form turn off the visibility of the subform??
 
Perhaps this:
Code:
Me.Sessions.Form.butBackCtlPnl03.Visible = False
"Sessions" is the name of your subform control, right?
 
Thanks for the two replies, Meltdown and Sergeant.

Meltdown, same thing happened again with me.frmSessions.visible=false .... it is trying to interpret frmSessions as a field and returns an error.

However,

Code:
Me.Sessions.Form.butBackCtlPnl03.Visible = False

DID work. Thanks again Sergeant.

It is interesting that 1) Meltdown was so sure that his code was OK and 2) the following code snippet from a routine in a quite different database

Code:
Me![frmInputBaby]!Label166.Caption = 1

works perfectly!

So, the question is, why?

Could it be that some subforms are placed on a main form without a control holder? ... this would explain the anomaly.

To check this, I looked back at my above-quoted database and the heirarchical structure (shown by means of clicking the top-left form select boxes in order) of the main to subform is Form.NameOfForm.Form as opposed to Form.NameOfControl.Form in my current database. This has a crazy logic to it and certainly would explain the apparent difference!

Would you or any other Access experts care to comment on this?
 
I think the confusion is caused because the subform control (container) is usually named the same as the form that it contains. What Meltdown posted was correct syntax, but I don't think he realized that your subform control was named "Sessions" and the form in it was named "frmSessions".

Sarge.
Not an Access expert. (It's all relative)
 

Users who are viewing this thread

Back
Top Bottom