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: 1
Default Excel VBA - Cursor disappears when validating content of a TextBox

I ask you friend's help for this problem:

I designed a form with several TextBoxes, some of which I need to check
to prevent input of invalid data, with some criteria I previously
defined (for instance, input must be an integer, between 1 and 999,
inclusive).

Then, with the BeforeUpdate event, I display a MsgBox to alert user,
and I want the focus to return to the TextBox with the invalid entry,
in order to be changed to a valid one.

My code worked fine except for a strange thing: cursor disappears when
user clicks "Ok", and seems to be nowhere, as pressing Tab, Shift-Tab,
Esc or Enter doesn't any effect.

If user wants to start all up again, I must to make invisible the frame
in which that TextBox is, but then VB returns an runtime error
'-2147418113 (8000ffff)'. It seems that MSForms does something in those
situations that takes the focus off any part of my application. I need
somebody who understands it to explain it to me, please.

Thank you all folks very much! My code is below.


Private Sub TextBox_BeforeUpdate(ByVal Cancel As
MSForms.ReturnBoolean)
If IsNumeric(TextBox.Value) Then
If CInt(TextBox.Value) < 1 Or CInt(TextBox.Value) 999 Then
If MsgBox("Entry must be between 1 and 999. Click (OK) to
enter new dara, or (Cancel) to clean form up and start again",
vbOKCancel + vbExclamation, "Attention!") = vbCancel Then
Cancel = False
Frame1.Visible=False
Else
TextBox= ""
TextBox.SetFocus
Cancel = True
Exit Sub
End If
End If
Else
BotCaixa = MsgBox("Entry must be an INTEGER, between 1 and
999.", vbOKOnly + vbExclamation, "Attention!")
TextBox = ""
TextBox.SetFocus
Cancel = True
End If
End Sub


---
Message posted from http://www.ExcelForum.com/

 
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 disappears from Excel paste into PowerPoint NickSteel Charts and Charting in Excel 0 December 6th 05 05:17 PM
Textbox disappears in large chart-Excel bug? [email protected] Excel Discussion (Misc queries) 2 November 1st 05 03:13 PM
Textbox disappears B. Scace Charts and Charting in Excel 2 August 29th 05 11:59 PM
How to move cursor from one textbox control to another textbox con Tom Ogilvy Excel Programming 1 September 16th 04 03:42 PM
Validating Entry into Textbox Brad[_11_] Excel Programming 1 December 4th 03 02:58 PM


All times are GMT +1. The time now is 07:14 PM.

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"