Hi could someone please solve this one for me as I really am totally baffled and really don't know what is causing the issue!
So I have a textbox 'textboxSaleNotes' on a Userform coded as below
This all works as expected if I test it and simply go into the box type something and then exit the box but the end user has to complete various other boxes first and dependent on their responses to some msgboxes they will eventually end up in the notes textbox (its the final box on the form).
The textbox is disabled on the form initialize and then enabled just after - again this all works as expected.
But for some reason as soon as the code below is run the notes textbox simply will not go to the backcolor I've set it to (blue). However if I comment out the setfocus bit it does but I need it to get the focus as well.
Can anyone see what I'm doing wrong or missing here?
Many thanks for and responses. Paul
So I have a textbox 'textboxSaleNotes' on a Userform coded as below
VBA Code:
Private Sub textboxSaleNotes_Enter()
textboxSaleNotes.BackColor = RGB(204, 255, 255)
End Sub
Private Sub textboxSaleNotes_Change()
textboxSaleNotes.Value = Application.WorksheetFunction.Proper(textboxSaleNotes.Value)
End Sub
Private Sub textboxSaleNotes_Exit(ByVal Cancel As MSForms.ReturnBoolean)
textboxSaleNotes.BackColor = RGB(255, 255, 255)
End Sub
This all works as expected if I test it and simply go into the box type something and then exit the box but the end user has to complete various other boxes first and dependent on their responses to some msgboxes they will eventually end up in the notes textbox (its the final box on the form).
The textbox is disabled on the form initialize and then enabled just after - again this all works as expected.
But for some reason as soon as the code below is run the notes textbox simply will not go to the backcolor I've set it to (blue). However if I comment out the setfocus bit it does but I need it to get the focus as well.
VBA Code:
Private Sub txtQty1_AfterUpdate()
Dim MsgReply1 As VbMsgBoxResult
Dim MsgReply2 As VbMsgBoxResult
If IsNumeric(txtQty1) And txtQty1.Value >= 1 Then
MsgReply1 = MsgBox("Do you want to enter another product?", vbQuestion + vbYesNo, "Add Next Product")
If MsgReply1 = vbYes Then
ComboProd2.SetFocus
Else
ComboProd2.Enabled = False
txtQty2.Enabled = False
MsgReply2 = MsgBox("Do you want to enter any notes about this record?", vbQuestion + vbYesNo, "Add Notes")
If MsgReply2 = vbYes Then
textboxSaleNotes.BackColor = RGB(204, 255, 255)
textboxSaleNotes.SetFocus
End If
End If
End If
End Sub
Can anyone see what I'm doing wrong or missing here?
Many thanks for and responses. Paul