Solved

Change a control on a sub form

Posted on 2011-02-23
11
218 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
  • 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 84
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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

773 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