Solved

Change a control on a sub form

Posted on 2011-02-23
11
221 Views
Last Modified: 2012-05-11
I have a form with a subform. I am trying to set a control on the subform:
Processed.enabled = -1
I am doing this from a routine outside of the form.

I am setting a control on the main form using "frmProgramInformaiton.Processed.enabled = -1"

The latest syntax i have tried after reading solutions in the DB is:
"Forms!frmProgramInformation!frmsubSubProgram.Form!Processed.enabled = -1)

The Main form is "frmPrograminformation"
the subform is "frmsubSubProgram"

The control is the same on both forms 'Processed"

I share an update routine with several forms so i want to pass the name to it and then update the field.

Thanks for your help
0
Comment
Question by:ChuckRush
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
11 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 34960920
Forms!frmProgramInformation!subformcontainercontrolname.Form!Processed.enabled = -1

subformcontainercontrolname is the name of the container control on the main form that holds the subform.  It can be the same or different to the name of the subform, depending on how the subform was created.
0
 
LVL 85
ID: 34961058
Peter is almost certainly correct in this, but to give a little more info:

One way to insure you're working with the actual Subform control is open the Main form in Design view and click the Subform ONCE. Review the Properties for THAT control. If it contains a Property named "Source Object", then you've got the right control. If it does NOT, then you need to try again.

Also, the Subform CONTROL has only two events - Enter and Exit. If you click the Events table AFTER selecting the control and you see more than those two events, then you haven't referenced the correct control.
0
 

Author Comment

by:ChuckRush
ID: 34961336
Forms!frmProgramInformation!frmSubSubProgram.Form![Processed].enabled = -1

Returns a Form not found error

The sub form name is 'frmSubSubProgram'  the control is named the same.
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 77

Expert Comment

by:peter57r
ID: 34961460
And the form/subform is definitely open?
0
 

Author Comment

by:ChuckRush
ID: 34961554
It is open in design mode

I have been doing some experimenting and this works:
          gFormName1 = "frmProgramInformation!frmSubSubProgram.Form"
          Forms(gformname).Form.AllowEdits = True

However when I try to add a control name:
 Forms(gFormName1).Controls(MilestonesAdded) = -1
I get the form not found.

MilestonesAdded is the actual control name on the subform
0
 

Author Comment

by:ChuckRush
ID: 34961589
I have tried ...Controls("MilestonesAdded")
                       Controls![MilestonesAdded]

0
 
LVL 77

Expert Comment

by:peter57r
ID: 34961803
....It is open in design mode....
..and the point of that is what?


I can do this  from one form to enable/disable a control on a different main/subform

Private Sub Command0_Click()
Static vis As Boolean
Forms![employee details]![Orders subform].Form![order total].Enabled = vis
vis = Not vis
End Sub
0
 

Author Comment

by:ChuckRush
ID: 34961980
Progress!

This works
Forms![frmProgramInformation]![frmSubSubProgram].Form![MilestonesAdded].Enabled = -1
I need to replace the form names with variables
0
 
LVL 77

Expert Comment

by:peter57r
ID: 34962185
Apart from the specific control involved I can't see any difference between what you say is working and what you said was  not working.

Forms![frmProgramInformation]![frmSubSubProgram].Form![MilestonesAdded].Enabled = -1
Forms!frmProgramInformation!frmsubSubProgram.Form!Processed.enabled = -1
0
 
LVL 77

Accepted Solution

by:
peter57r earned 125 total points
ID: 34962233
If you want to make a callable function you will need a syntax of ...

Forms(mainform).Controls(subformcontainername).Form.Controls(targetcontrolname).enabled = True

where mainform, subformcontainername and targetcontrolname are the function arguments and whose values are passed as strings to the function.
0
 

Author Closing Comment

by:ChuckRush
ID: 34962330
Outstanding! Thanks a lot
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question