userform - user must enter name to begin

ajm

Well-known Member
Joined
Feb 5, 2003
Messages
1,735
Hi, how do i set up a userform to make users enter their name before they can proceed? I don't want to use an inputbox before the form is called as the form is meant to help them save time while answering telephone calls. Currently, their is just a text box for them to input their name but most don't. this makes tracking who made what changes difficult.
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
8,760
Office Version
2007
Platform
Windows
If you have a button in the userform to save the data on the sheet, there you can put the following:

Code:
Private Sub CommandButton1_Click()
  If TextBox20 = "" Then
    MsgBox "Enter your name", vbCritical, "SAVE DATA CANCELED"
    TextBox20.SetFocus
    Exit Sub
  End If
  '
  'Continue your code to save the data on the sheet.
  '
End Sub
 

ajm

Well-known Member
Joined
Feb 5, 2003
Messages
1,735
If you have a button in the userform to save the data on the sheet, there you can put the following:

Code:
Private Sub CommandButton1_Click()
  If TextBox20 = "" Then
    MsgBox "Enter your name", vbCritical, "SAVE DATA CANCELED"
    TextBox20.SetFocus
    Exit Sub
  End If
  '
  'Continue your code to save the data on the sheet.
  '
End Sub
cheers Dante. that should do the trick nicely. I have a button to add the data to the report so will put your snippet in. Fantastic.
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
8,760
Office Version
2007
Platform
Windows
I'm glad to help you. Thanks for the feedback.
 
  • Like
Reactions: ajm

Forum statistics

Threads
1,081,703
Messages
5,360,747
Members
400,595
Latest member
T_Dubs

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top