Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / November 2007

Tip: Looking for answers? Try searching our database.

How do I access the controls on one form from the code module of     another?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chrisso - 27 Nov 2007 17:21 GMT
Hi All

I have one form with a command button. When this command button is
clicked I open another form - I then want to change some of the
controls on this form from the code of the starting form:

      DoCmd.OpenForm "cFrmDocFullDetails"                         '
launch form
      ' now set the required fields backgrounf colour to pale yellow:
      ' argh! dont know how to access this form

How do I access the controls on one form from the code module of
another? I cannot work out how to get a handle on the form that I jsut
opened. Can I loop through all the forms or something? Can I straight
instantiate an object that is the form?

I have another similar question - when I open the form why cant I do
something like this:
    ThisDatabase.cFrmDocFullDetails.Show
or something similar. Is coding of this type possible?

Any help would be great.

Thanks
Chrisso
ruralguy - 27 Nov 2007 17:38 GMT
You can go through the Forms collection:
Forms.OtherFormName.ControlName

...using your form and control names of course.  Only forms that are open are
in the Forms collection.

>Hi All
>
[quoted text clipped - 21 lines]
>Thanks
>Chrisso

Signature

RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro
Please post back to this forum so all may benefit.

Dale Fye - 27 Nov 2007 18:32 GMT
All of the methods shown below will allow you to reference a control on
another form.  The advantage of the first one is that it will provide you
with intellisense, so you can see the name of the controls as well as that
controls properties while you are typing, whereas in the other two methods,
you have to know the controls name and the applicable properties.

Form_frm_Employees.txt_FieldName.backcolor = 255
Forms("frm_Employees").Controls("txt_FieldName").BackColor = 255
Forms.frm_Employees.txt_FieldName.BackColor = 255

HTH
Dale

Signature

Don''t forget to rate the post if it was helpful!

Email address is not valid.
Please reply to newsgroup only.

> Hi All
>
[quoted text clipped - 21 lines]
> Thanks
> Chrisso
Chrisso - 27 Nov 2007 19:26 GMT
> All of the methods shown below will allow you to reference a control on
> another form.  The advantage of the first one is that it will provide you
[quoted text clipped - 40 lines]
> > Thanks
> > Chrisso

Thanks RG and Dale. Cheers Chrisso
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.