unbound textbox storing value

awake2424

Registered User.
Local time
Yesterday, 23:07
Joined
Oct 31, 2007
Messages
479
Code:
Private Sub Combo1309_AfterUpdate()
   If Me.Combo1309.Value = "Yes" Then
   Me.Text1307 = Environ("UserName")
   Me.Patient_Gender.BackColor = vbYellow
   
   ElseIf Me.Combo1309.Value = "No" Then
   Me.Text1307 = Environ("UserName")
   Me.Patient_Gender.BackColor = vbRed
   
End If
End Sub

I have the above code in an unbound textbox and it functions correctly. Expect, the value Yes/No appears in every record in that textbox,

So, if in record 1 the value of that textbox 1309 is Yes in record 2,3,4 the value of that textbox 1309 is set to Yes. How do I make it blank until the user selects the proper choice. Thanks.
 
Based on your Code, the Unbound Text Box (Me.Text1307) value will be set with the Window's Username. This is true if the Combo box (Me.Combo1309.Value) value is Yes or No.

You said it is an unbound text box, if that is true then it's control source property is not set with a field name and the Window's Username is not stored anywhere in the bound Table. Only the Patient Gender control's back color is changed.

If you want the Textbox to be blank when the combobox selection is "No" then the code can be modified as below:

Code:
Private Sub Combo1309_AfterUpdate()
   If Me.Combo1309.Value = "Yes" Then
   Me.Text1307 = Environ("UserName")
   Me.Patient_Gender.BackColor = vbYellow
   
   ElseIf Me.Combo1309.Value = "No" Then
   Me.Text1307 = Null
   Me.Patient_Gender.BackColor = vbRed
   
End If
End Sub
 
Last edited:

Users who are viewing this thread

Back
Top Bottom