I need some help in evaluating UserForm data entries. When the User clicks a cmd button, I have some code that evaluates the controls on the UserForm. When something is incorrect, I want to give the User an opportunity to make the necessary correction, and then have the code continue. Now, when the User makes the correction, I want that updated data to map back to the appropriate field on the UserForm.
I did some Googling and found that an Input Box might be the best solution, so I have the code listed below (2nd set). The code is identifying the error, and throwing the Input Box. However, the value entered into the Input Box isn't mapping back to the UserForm. Instead, it just flows to the next evaluation.
How can I get the data on the Input Box to flow back to the UserForm?
In all reality, my preference is to return the User to the actual field on the UserForm, since I have a lot of code validating the data entered in those controls, and reformatting them. I was using this code (1st set), but I couldn't get the focus to set on the field.
I did some Googling and found that an Input Box might be the best solution, so I have the code listed below (2nd set). The code is identifying the error, and throwing the Input Box. However, the value entered into the Input Box isn't mapping back to the UserForm. Instead, it just flows to the next evaluation.
How can I get the data on the Input Box to flow back to the UserForm?
In all reality, my preference is to return the User to the actual field on the UserForm, since I have a lot of code validating the data entered in those controls, and reformatting them. I was using this code (1st set), but I couldn't get the focus to set on the field.
Code:
Case Me.txt_Nickname.Value = "" MsgBox "Please enter a Nickname for the Client."
If response = vbOK Then Me.txt_Nickname.SetFocus
Exit Sub
IsOk = False
Code:
Private Sub cmd_Submit_Click()
Dim cGender, cEntryType, cPymtFreq, cPymtStatus, cStatus, cPymtMethod, cRefCat, cFacilitator, cPymtReason, cBiosClientID, cBiosNickname, cStatsClientID As Range
Dim ws1, ws2, ws3, ws4, ws5, ws6, ws7 As Worksheet
Dim DataCorr As Variant
Dim Response As VbMsgBoxResult
Dim IsOk As Boolean
IsOk = True
Set ws1 = ThisWorkbook.Sheets("Management")
Set ws2 = ThisWorkbook.Sheets("Summaries")
Set ws3 = ThisWorkbook.Sheets("Bios")
Set ws4 = ThisWorkbook.Sheets("Stats")
Set ws5 = ThisWorkbook.Sheets("Pymt Tracker")
Set ws6 = ThisWorkbook.Sheets("Financials")
Set ws7 = ThisWorkbook.Sheets("Variables")
LastRow2 = ws2.Range("C" & Rows.Count).End(xlUp).Row
LastRow3 = ws3.Range("E" & Rows.Count).End(xlUp).Row
LastRow4 = ws4.Range("C" & Rows.Count).End(xlUp).Row
LastRow5 = ws5.Range("C" & Rows.Count).End(xlUp).Row
LastRow6 = ws6.Range("D" & Rows.Count).End(xlUp).Row
LastRow7 = ws7.Range("J" & Rows.Count).End(xlUp).Row
If Len(Me.txt_Nickname.Value) = 0 Then
DataCorr = InputBox("Please enter a unique nickname for the Client.", "Data Correction")
If Response = vbOK Then Me.txt_Nickname.Value = DataCorr.Value
End If
If Len(Me.txt_Email.Value) = 0 Then
DataCorr = InputBox("Please enter the Client's email address.", "Data Correction")
If Response = vbOK Then Me.txt_Email.Value = DataCorr.Value
End If
Last edited: