UserForm Data Correction and Input Boxes

reberryjr

Well-known Member
Joined
Mar 16, 2017
Messages
714
Office Version
  1. 365
Platform
  1. Windows
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.

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:
That's the idea, yes.
You can stick with doing the validation in the cmd_Submit event, but the problem is rechecking the input value to ensure that you have the correct data.
 
Upvote 0

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top