How do I populate a control from data in another control?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi I have a check box control [COPD] and a memo control [Problem List] in a
subform. I would like the [Problem List] control to be populated with the
word "COPD" everytime the [COPD] check box is checked. In the same manner I
would like it to clear [Problem List] if [COPD] is unchecked. Would
appreciate any suggestions. Thank you.
 
Are COPD and Problem List field names? Is so, you would do well to name the
controls chkCOPD and txtProblemList or something like that. It's a good
idea to use a naming convention for controls whether they are bound or not.
In the After Update event for chkCOPD:

If Me.chkCOPD = True Then
Me.txtProblemList = "COPD"
Else
Me.txtProblemList = ""
End If

You will need the same code in the form's Current event if txtProblemList is
an unbound text box (as it should be, from what information is available).
 
If the check box control [COPD] located in the subform then on the
AfterUpdate event of the check box you can write the code
If Me.[COPD] Then ' control is checked
Me.[Problem List] = "COPD"
Else
Me.[Problem List] = ""
End If
=====================================
If the check box control [COPD] located in the MainForm then on the
AfterUpdate event of the check box you can write the code
If Me.[COPD] Then ' control is checked
Me.[WriteHereSubFormControlName].Form![Problem List] = "COPD"
Else
Me.[WriteHereSubFormControlName].Form![Problem List] = ""
End If
=====================================
Why do you need a Memo field type for such a short text?
 
Thank you BruceM. I should have mentioned that I would like the control to
update while the form is still open. My understanding is that the After
Update event will update this once the Record is saved. [COPD] and [Problem
List] are field names and I have named the controls the same. Is that
causing problems?

BruceM said:
Are COPD and Problem List field names? Is so, you would do well to name the
controls chkCOPD and txtProblemList or something like that. It's a good
idea to use a naming convention for controls whether they are bound or not.
In the After Update event for chkCOPD:

If Me.chkCOPD = True Then
Me.txtProblemList = "COPD"
Else
Me.txtProblemList = ""
End If

You will need the same code in the form's Current event if txtProblemList is
an unbound text box (as it should be, from what information is available).

AMN said:
Hi I have a check box control [COPD] and a memo control [Problem List] in
a
subform. I would like the [Problem List] control to be populated with the
word "COPD" everytime the [COPD] check box is checked. In the same manner
I
would like it to clear [Problem List] if [COPD] is unchecked. Would
appreciate any suggestions. Thank you.
 
Thank you Ofer Cohen. I don't know how to use VB. Is there a way to do this
by using the Expression Builder? Also the text is going to be longer, I just
simplified it for the purposes of this inquiry. I should mention that I
would like the control to update while the form is still open.

Ofer Cohen said:
If the check box control [COPD] located in the subform then on the
AfterUpdate event of the check box you can write the code
If Me.[COPD] Then ' control is checked
Me.[Problem List] = "COPD"
Else
Me.[Problem List] = ""
End If
=====================================
If the check box control [COPD] located in the MainForm then on the
AfterUpdate event of the check box you can write the code
If Me.[COPD] Then ' control is checked
Me.[WriteHereSubFormControlName].Form![Problem List] = "COPD"
Else
Me.[WriteHereSubFormControlName].Form![Problem List] = ""
End If
=====================================
Why do you need a Memo field type for such a short text?
--
HTH, Good Luck
BS"D


AMN said:
Hi I have a check box control [COPD] and a memo control [Problem List] in a
subform. I would like the [Problem List] control to be populated with the
word "COPD" everytime the [COPD] check box is checked. In the same manner I
would like it to clear [Problem List] if [COPD] is unchecked. Would
appreciate any suggestions. Thank you.
 
Although I have never used VB. Based on your suggestion I did what you told
me in the OnExit code and it works perfectlly. Thank you very much.

Ofer Cohen said:
If the check box control [COPD] located in the subform then on the
AfterUpdate event of the check box you can write the code
If Me.[COPD] Then ' control is checked
Me.[Problem List] = "COPD"
Else
Me.[Problem List] = ""
End If
=====================================
If the check box control [COPD] located in the MainForm then on the
AfterUpdate event of the check box you can write the code
If Me.[COPD] Then ' control is checked
Me.[WriteHereSubFormControlName].Form![Problem List] = "COPD"
Else
Me.[WriteHereSubFormControlName].Form![Problem List] = ""
End If
=====================================
Why do you need a Memo field type for such a short text?
--
HTH, Good Luck
BS"D


AMN said:
Hi I have a check box control [COPD] and a memo control [Problem List] in a
subform. I would like the [Problem List] control to be populated with the
word "COPD" everytime the [COPD] check box is checked. In the same manner I
would like it to clear [Problem List] if [COPD] is unchecked. Would
appreciate any suggestions. Thank you.
 
Although I have never used VB. Based on your suggestion I did what you told
me in the OnExit code and it works perfectlly. Thank you very much.

BruceM said:
Are COPD and Problem List field names? Is so, you would do well to name the
controls chkCOPD and txtProblemList or something like that. It's a good
idea to use a naming convention for controls whether they are bound or not.
In the After Update event for chkCOPD:

If Me.chkCOPD = True Then
Me.txtProblemList = "COPD"
Else
Me.txtProblemList = ""
End If

You will need the same code in the form's Current event if txtProblemList is
an unbound text box (as it should be, from what information is available).

AMN said:
Hi I have a check box control [COPD] and a memo control [Problem List] in
a
subform. I would like the [Problem List] control to be populated with the
word "COPD" everytime the [COPD] check box is checked. In the same manner
I
would like it to clear [Problem List] if [COPD] is unchecked. Would
appreciate any suggestions. Thank you.
 
Back
Top