I hope someone is able to help me.
I have a textbox on my userform that is populated during the userform's initialization code. It is taken from a reference database.
The user has the opportunity to change the value on the userform. If the user edits it, I have it set up that when they leave that text box they are prompted with a message giving the option to make the change permanent in the reference database. I am using a before update event for that. This works, however, the next time I simply click on that textbox, and before any edit, I get the prompt. I then get again upon exiting if I make an edit.
What can I do to prevent it from triggering the code when I click on the field in subsequent approaches?
Private Sub tb_event_beforeupdate(ByVal CANCEL As MSForms.ReturnBoolean)
Dim cn As Long
Dim rn_dest As Long
Dim ui1 As VbMsgBoxResult
If mbEvents Then Exit Sub
'mbEvents = False
rn = Application.WorksheetFunction.Match(lrid, ws_data.Range("A:A"), 0)
If Trim(tb_event.Value & vbNullString) = vbNullString Then
MsgBox "This field is mandatory and cannot be blank." & Chr(13) & "Please enter an event name.", vbCritical, "ERROR"
tb_event = ws_data.Range("F" & rn)
Else
ui1 = MsgBox("{event} Would you like to apply this change to the entire rental agreement?", vbQuestion + vbYesNo, "RENTAL INFORMATION")
If ui1 = vbYes Then
cn = ws_data.Range("C" & rn)
With ws_rd
rn_dest = .Range("A:A").Find(cn).row
.Range("D" & rn_dest) = tb_event.Value
End With
MsgBox "{event} Information for rental #" & cn & " changed successfully.", vbInformation, "CONFIRMATION"
End If
End If
tb_event.BackColor = RGB(255, 255, 255)
'mbEvents = False
End Sub
Display More
I get the same results with an afterupdate event.