Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default problem with my code for incorrect text box inputs on a userform

On my spreadsheet I have a user form that loads up where their are two text
boxes on for the First Name and another for the Last Name. With the help of
Tom I have created a macro that takes the input from the text boxes and takes
the user to their corresponding range.

The problem I am having is if an incorrect user name is entered such as "Bob
Dole" I get a run time error instead of the message box that is entered in
my code. Below is the code I have. Can someone tell me what is wrong with
my IF rng=nothing I keep getting an object not defined error message on it
when the wrong name is inputed.

Private Sub Login_click()
With UserInterface
On Error Resume Next
Set rng = Worksheets("Employee Tracker").Range( _
.TextboxFirst.Text & "_" & .TextBoxLast.Text)
On Error GoTo 0
If rng Is Nothing Then
MsgBox "Bad name, quitting"
Unload UserInterface
ThisWorkbook.Close Savechanges:=False
End If
End With
Worksheets("Employee Tracker").Unprotect Password:="testpass"
Range("A5:N25").Select
Selection.Locked = True
Application.Goto rng, True
Unload UserInterface
Call Macro3
End Sub


Thanks in advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 272
Default problem with my code for incorrect text box inputs on a userform

Have you given any thought to using a ComboBox to have the user select the
name rather than typing it? That might help prevent typos
--
Charles Chickering

"A good example is twice the value of good advice."


"BrianMo" wrote:

On my spreadsheet I have a user form that loads up where their are two text
boxes on for the First Name and another for the Last Name. With the help of
Tom I have created a macro that takes the input from the text boxes and takes
the user to their corresponding range.

The problem I am having is if an incorrect user name is entered such as "Bob
Dole" I get a run time error instead of the message box that is entered in
my code. Below is the code I have. Can someone tell me what is wrong with
my IF rng=nothing I keep getting an object not defined error message on it
when the wrong name is inputed.

Private Sub Login_click()
With UserInterface
On Error Resume Next
Set rng = Worksheets("Employee Tracker").Range( _
.TextboxFirst.Text & "_" & .TextBoxLast.Text)
On Error GoTo 0
If rng Is Nothing Then
MsgBox "Bad name, quitting"
Unload UserInterface
ThisWorkbook.Close Savechanges:=False
End If
End With
Worksheets("Employee Tracker").Unprotect Password:="testpass"
Range("A5:N25").Select
Selection.Locked = True
Application.Goto rng, True
Unload UserInterface
Call Macro3
End Sub


Thanks in advance

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default problem with my code for incorrect text box inputs on a userfo

I did but it is very important that other workers can not fill in the name of
another employee and since it has to be exact spelling having them type it in
alleviates this. The reason i need to have a message box come up if a user
name is not correct is not specifically in my department but for the others
that will be using this sheet for their own departments.

"Charles Chickering" wrote:

Have you given any thought to using a ComboBox to have the user select the
name rather than typing it? That might help prevent typos
--
Charles Chickering

"A good example is twice the value of good advice."


"BrianMo" wrote:

On my spreadsheet I have a user form that loads up where their are two text
boxes on for the First Name and another for the Last Name. With the help of
Tom I have created a macro that takes the input from the text boxes and takes
the user to their corresponding range.

The problem I am having is if an incorrect user name is entered such as "Bob
Dole" I get a run time error instead of the message box that is entered in
my code. Below is the code I have. Can someone tell me what is wrong with
my IF rng=nothing I keep getting an object not defined error message on it
when the wrong name is inputed.

Private Sub Login_click()
With UserInterface
On Error Resume Next
Set rng = Worksheets("Employee Tracker").Range( _
.TextboxFirst.Text & "_" & .TextBoxLast.Text)
On Error GoTo 0
If rng Is Nothing Then
MsgBox "Bad name, quitting"
Unload UserInterface
ThisWorkbook.Close Savechanges:=False
End If
End With
Worksheets("Employee Tracker").Unprotect Password:="testpass"
Range("A5:N25").Select
Selection.Locked = True
Application.Goto rng, True
Unload UserInterface
Call Macro3
End Sub


Thanks in advance

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help selecting a range in vba from userform inputs grievesy[_3_] Excel Programming 3 April 27th 06 10:28 PM
Automated userform inputs to the spreadsheet Dan Excel Programming 2 June 11th 04 04:54 PM
Automated userform inputs to the spreadsheet Dan Excel Programming 1 June 11th 04 04:54 PM
userform inputs Jo[_4_] Excel Programming 1 September 19th 03 11:36 PM
userform inputs Jouni Excel Programming 0 September 19th 03 10:51 PM


All times are GMT +1. The time now is 06:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"