If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
How do I access the controls on one form from the code module ofanother?
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 |
#2
|
|||
|
|||
How do I access the controls on one form from the code module ofanother?
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. Chrisso wrote: 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 (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro Please post back to this forum so all may benefit. Message posted via http://www.accessmonster.com |
#3
|
|||
|
|||
How do I access the controls on one form from the code module of a
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").B ackColor = 255 Forms.frm_Employees.txt_FieldName.BackColor = 255 HTH Dale -- Don''t forget to rate the post if it was helpful! Email address is not valid. Please reply to newsgroup only. "Chrisso" wrote: 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 |
#4
|
|||
|
|||
How do I access the controls on one form from the code module ofa
On 27 Nov, 18:32, Dale Fye wrote:
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").B ackColor = 255 Forms.frm_Employees.txt_FieldName.BackColor = 255 HTH Dale -- Don''t forget to rate the post if it was helpful! Email address is not valid. Please reply to newsgroup only. "Chrisso" wrote: 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 Thanks RG and Dale. Cheers Chrisso |
Thread Tools | |
Display Modes | |
|
|