Subform calling main form control visible

latex88

Registered User.
Local time
Today, 14:04
Joined
Jul 10, 2003
Messages
198
I want a button in a subform to trigger a label and text box to become visible in the main form. Isn't the code quite straightforward like below? It does not seem to work.

Forms!MainForm.ControlName.Visible = True
 
I tried that before, but received "Method or data member not found".
 
I have this working code in production, having a subform set focus back to itself:

Code:
'As this form is used within a subform control, necessary to setfocus
'to the subform control first, then the control itself which is on the subform form
Me.Parent.subform_quality.SetFocus
Me.fldid.SetFocus
Oh... and I seem to recall some syntax that for subforms it is necessary to put .Form. in the call syntax at sometimes... I will see if I have a use example of that call syntax... No hits, sorry.
 
Oh... and I seem to recall some syntax that for subforms it is necessary to put .Form. in the call syntax at sometimes... I will see if I have a use example of that call syntax... No hits, sorry.

I found when to use that syntax:

"How to refer to subforms in control sources "
http://www.btabdevelopment.com/ts/refer2sfrms

When wanting to use any of the controls, methods, or properties of the actual subform, you must use .Form. to tell Access you are referring to the form and not the subform container control.
 
2 guesses: 1) AllForms!MainForm.ControlName.Visible = True this is how you modify an unloaded form, maybe good also for out-of-focus control.. 2) Me.Parent!ControlName.Visible = True
 
Oh... and I seem to recall some syntax that for subforms it is necessary to put .Form. in the call syntax at sometimes... I will see if I have a use example of that call syntax... No hits, sorry.

Helps to search the entire database and not just the current form! ;)

Code:
  'Populate the form fields from the attributes
  MePointer.flduserid.Value = Me.userid
  MePointer.fldusername.Value = Me.username
  MePointer.fldactive.Value = Me.active
  MePointer.fldemailaddy.Value = Me.emailaddy
[B]  MePointer[COLOR=Red].child_subform_lastsaved.Form.[/COLOR]fldlastsaveusername.Value = Me.authusername
  MePointer[COLOR=Red].child_subform_lastsaved.Form.[/COLOR]fldlastsavelogtimestamp.Value = Me.logtimestamp[/B]
So in this example, the Form code has passed a pointer to itself (Me) when it called the class method. The class method receives that pointer into variable ByRef MePointer. The code then populates Form controls, including a couple of fields which are on a subform of the calling Form.
 
Well, I'm not sure what the problem was, but when I first tested the code, I only asked for the label on the main form to be visible by using
Me.Parent.myLabel.Visible = True
That never worked, so I was convinced the syntax is not right. But from all the research, it just seems that simple, so I made the associated text box visible too with
Me.Parent.myTextbox.Visible = True
For some reason, when I included the text box, then both became visible. I always thought you can separate the labels and the text boxes separately.

Oh well, it works now. Thanks for all your help.
 
For some reason, when I included the text box, then both became visible. I always thought you can separate the labels and the text boxes separately.

I believe you may disconnect the Text Control from the Field Control, and then perhaps you could hide the Text Control separately. I missed the point that you were trying to hide a Text Control which was created with a Field Control.

The admin UI should be in the Grouping area of the Form editor which controls that.
 

Users who are viewing this thread

Back
Top Bottom