Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Exit Event with a single textbox control

I'd like to password protect some features of a spreadsheet, so to take
advantage of the PasswordChar Property of a Textbox control, I created
a small userform with only a text box on it. My intention was to
replace the InputBox function since it doesn't allow character
protection. Unfortunately, with no other controls on the form it
appears that I can't get the exit event to fire without closing the
userform...

If I put another text box on the userform, the exit event fires just
fine when I tab out of the first control.

Am I missing something?

Here are the applicable code fragments
'
' From a UserForm called PSSDataForm
'
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As
Integer)
Load PasswordDataForm
PasswordDataForm.Show
End Sub

'
' From PasswordDataForm
' PasswordBox is the textbox control where I enter the password
'
Sub PasswordBox_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If PasswordBox.Value = ClosurePassword Then
Unload PSSDataForm
Unload PasswordDataForm
Else
'
' Do other stuff here
'
End If
End Sub

Excel 2002, all current service packs applied, runnning on XP Pro SP1.
(Don't start - its my work laptop and we haven't rolled out SP2 yet...)

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Exit Event with a single textbox control

ChazE911,
Some control needs to have the focus. If you only have a single control,
there is nowhere for the focus to go.
You could at least put a Cancel and/or OK button also, otherwise the user
may get stuck in a loop if they cannot supply the correct PW.

NickHK

wrote in message
oups.com...
I'd like to password protect some features of a spreadsheet, so to take
advantage of the PasswordChar Property of a Textbox control, I created
a small userform with only a text box on it. My intention was to
replace the InputBox function since it doesn't allow character
protection. Unfortunately, with no other controls on the form it
appears that I can't get the exit event to fire without closing the
userform...

If I put another text box on the userform, the exit event fires just
fine when I tab out of the first control.

Am I missing something?

Here are the applicable code fragments
'
' From a UserForm called PSSDataForm
'
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As
Integer)
Load PasswordDataForm
PasswordDataForm.Show
End Sub

'
' From PasswordDataForm
' PasswordBox is the textbox control where I enter the password
'
Sub PasswordBox_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If PasswordBox.Value = ClosurePassword Then
Unload PSSDataForm
Unload PasswordDataForm
Else
'
' Do other stuff here
'
End If
End Sub

Excel 2002, all current service packs applied, runnning on XP Pro SP1.
(Don't start - its my work laptop and we haven't rolled out SP2 yet...)



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Exit Event with a single textbox control

I just tried that basic solution. I added a second text box that's
VERY small and put it in the form as an overlay on the 'main' text box.
Kind of a kludge, I guess, but it works.

Thanks for the input.

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
Textbox added to Form at runtime too small, can't control size andchange event won't trigger RCGUA Excel Worksheet Functions 2 December 10th 08 09:34 PM
Textbox added to Form at runtime too small, can't control size andchange event won't trigger RCGUA Excel Worksheet Functions 0 December 10th 08 07:48 PM
How To Get An Event To Run When I Exit A TextBox Minitman[_4_] Excel Programming 7 October 22nd 04 11:27 PM
MSForms.TextBox Exit event isn't available in Excel class mosule lacos Excel Programming 2 December 12th 03 10:12 AM
Control Exit event Fred Excel Programming 0 November 19th 03 12:59 AM


All times are GMT +1. The time now is 05:57 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"