?
Solved

Change a control on a sub form

Posted on 2011-02-23
11
Medium Priority
?
225 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 500 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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

650 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