My code correctly captures the value for the variable "IncidentRow", but I do not know how to call for that exact value within a commandbutton click event.
The value is originally captured via exiting a textbox:
'
And then I can confirm that it was indeed correctly found and captured via a MsgBox:
But, when I then go to use that variable (which should be 1136) in my Commandbutton code, it comes up as 'Zero':
How can i save the variable as the 1136 value and then recall it within the separate commandbutton code when it is triggered? Thank you.
The value is originally captured via exiting a textbox:
VBA Code:
Dim FoundCell As Range
Dim IncidentCell As Range
'
VBA Code:
Private Sub txtIncidentID1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim Search As String
Dim FoundCell As Range
Dim IncidentCell As Range
' Lookup the "Incident ID Number" in two worksheets: Sheet22 and in Sheet1. Save that value as 'FoundCell' (for worksheet22) and as 'IncidentCell' (for worksheet1)
Search = Me.txtIncidentID1.value
Set FoundCell = Sheet22.Range("B:B").Find(Search, LookAt:=xlWhole, LookIn:=xlValues)
Set IncidentCell = Sheet1.Range("A:A").Find(Search, LookAt:=xlWhole, LookIn:=xlValues)
If Not FoundCell Is Nothing Then
GetRecord FoundCell.Row
UpdateRecord IncidentCell.Row
Else
MsgBox Search & Chr(10) & "Incident ID not found.", 48, "Not Found"
Me.txtIncidentID1.value = ""
Cancel = True
End If
On Error Resume Next
End Sub
And then I can confirm that it was indeed correctly found and captured via a MsgBox:
VBA Code:
Sub UpdateRecord(ByRef IncidentRow As Long)
MsgBox IncidentRow
End Sub
But, when I then go to use that variable (which should be 1136) in my Commandbutton code, it comes up as 'Zero':
How can i save the variable as the 1136 value and then recall it within the separate commandbutton code when it is triggered? Thank you.