Solved

Change a control on a sub form

Posted on 2011-02-23
11
216 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
 
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

759 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now