Solved

Change a control on a sub form

Posted on 2011-02-23
11
219 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Suggested Solutions

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
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…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

828 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