LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Form focus

Hi, when I use the following macro to check a user password entry, if the
password is not found I want the textbox to clear and the focus to be back
there, after my "password incorrect" message. All seems ok except that the
very last command in my macro does not work, and the focus is set on another
area (the command button I use to exit). Any help will be grateful.

Private Sub TextBox1_AfterUpdate()

'Load the password database (data01.xlt).
Label01:
newpath = "\\XXX\data" : newfile = "data01.xlt" : ChDir newpath :
Workbooks.Open newfile : col = "D" : ro = 0

'Verify password. Close the password database (data01.xlt).
Label02:
ro = ro + 1 : newro = Str(ro) : MyLen = Len(newro) : ro = Right(newro,
(MyLen - 1)) : findcell = col + ro
Range(findcell).Select : datacheck = ActiveCell.FormulaR1C1
If datacheck = "" Then GoTo Label03
If datacheck < TextBox1 Then GoTo Label02

'Read the user's name. Close the password database (data01.xlt). Load the
main menu form.
Range("A" + ro).Select : username = ActiveCell.FormulaR1C1
Range("A1").Select : ActiveWorkbook.Close savechanges:=False
Sheets("DATA").Activate : Range("B2").Select ActiveCell.FormulaR1C1 = username
menuform.Show : End

'User password not found. Close the password database (data01.xlt). Return
to the form.
Label03:
ActiveWorkbook.Close savechanges:=False
Msg = "The password you entered has not been recognised" : Style = vbOKOnly
+ vbCritical
Title = "PASSWORD FAILURE" : Response = MsgBox(Msg, Style, Title)
TextBox1 = ""
passwordform.TextBox1.SetFocus
End Sub

 
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
Focus in a form Robert Pollock[_3_] Excel Programming 1 August 15th 07 12:55 PM
Set Focus Not working on a form [email protected] Excel Programming 1 December 22nd 06 04:56 PM
Form - Text Box Focus ceemo[_27_] Excel Programming 1 August 30th 05 07:50 PM
set focus on user form jhahes[_2_] Excel Programming 1 June 1st 05 09:26 PM
Sending Form Focus? Clint K. Excel Programming 0 May 23rd 04 03:16 AM


All times are GMT +1. The time now is 12:02 AM.

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

About Us

"It's about Microsoft Excel"