By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,836 Members | 2,097 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,836 IT Pros & Developers. It's quick & easy.

How to update a label caption in other forms in MS Access

P: 2
I have a text box called txtAttirubte1 and an update button in FormA. I want to update the label caption for all label name Attribute1_Lable in FormB and FormC with the WORD I type in the FormA text box, txtAttribute1. I have the following codes for the ON CLICK event of Update button on FormA.

Private Sub cmdUpdate_Click()
DoCmd.OpenForm "frm_FormB"
[Forms]![ frm_FormB]![Attribute1_Label].Caption = Me![txtAttirubte1].Value
DoCmd.Close acForm, frm_FormB, acSavePrompt

DoCmd.OpenForm "frm_FormC"
[Forms]![ frm_FormC]![Attribute1_Label].Caption = Me![txtAttirubte1].Value
DoCmd.Close acForm, frm_FormC, acSavePrompt
End Sub

However, it doesn’t work. Please help. Many thanks!

Webbi
Apr 2 '07 #1
Share this Question
Share on Google+
2 Replies


Missionary
P: 30
I have a text box called txtAttirubte1 and an update button in FormA. I want to update the label caption for all label name Attribute1_Lable in FormB and FormC with the WORD I type in the FormA text box, txtAttribute1. I have the following codes for the ON CLICK event of Update button on FormA.

Private Sub cmdUpdate_Click()
DoCmd.OpenForm "frm_FormB"
[Forms]![ frm_FormB]![Attribute1_Label].Caption = Me![txtAttirubte1].Value
DoCmd.Close acForm, frm_FormB, acSavePrompt

DoCmd.OpenForm "frm_FormC"
[Forms]![ frm_FormC]![Attribute1_Label].Caption = Me![txtAttirubte1].Value
DoCmd.Close acForm, frm_FormC, acSavePrompt
End Sub

However, it doesn’t work. Please help. Many thanks!

Webbi
An easy way to do this is to make a macro.
open frm_FormB
SetValue Item: [Forms]![ frm_FormB]![Attribute1_Label].caption
Expression: [Forms]![ frm_FormA]![Attribute1_Label].
Close Type: Form
Name: frm_FormB
Save: Prompt
open frm_FormC
SetValue Item: [Forms]![ frm_FormC]![Attribute1_Label].caption
Expression: [Forms]![ frm_FormA]![Attribute1_Label].
Close Type: Form
Name: frm_FormC
Save: Prompt

Set your update button to run the macro.
Feb 20 '08 #2

jaxjagfan
Expert 100+
P: 254
I have a text box called txtAttirubte1 and an update button in FormA. I want to update the label caption for all label name Attribute1_Lable in FormB and FormC with the WORD I type in the FormA text box, txtAttribute1. I have the following codes for the ON CLICK event of Update button on FormA.

Private Sub cmdUpdate_Click()
DoCmd.OpenForm "frm_FormB"
[Forms]![ frm_FormB]![Attribute1_Label].Caption = Me![txtAttirubte1].Value
DoCmd.Close acForm, frm_FormB, acSavePrompt

DoCmd.OpenForm "frm_FormC"
[Forms]![ frm_FormC]![Attribute1_Label].Caption = Me![txtAttirubte1].Value
DoCmd.Close acForm, frm_FormC, acSavePrompt
End Sub

However, it doesn’t work. Please help. Many thanks!

Webbi
Normally values are only available to a single form for use within that form for its functions and not available outside of that form. We need to make the value (In your case a string from FormA) a public value for use thru-out the app.

If you have a Module in your database add a public variable. If no module then add one.

Public vlbl as variant

On the AfterUpdate Property of txtAttirubte1 on FormA.

vlbl = Me.txtAttirubte1

On the OnLoad events of FormB and FormC

Me.Attribute1_Label.Caption = vlbl

Just remember next time you come into the app that the labels will go back to there default values.
Feb 20 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.