Textbox highlighting issue  
Author Message
isaacson





PostPosted: Tue Dec 27 14:23:59 CST 2005 Top

Excel Programming >> Textbox highlighting issue

I have a number of textboxes on a userform. When the user enters dat
beyond accepted paramaters,

1. an error message is generated
2. the form 'close' button is locked (& changes color)
3. the offending input textbox changes color.

I also would like the cursor to return to the offending textbox afte
step 3 - how do I do this ? (apologies for what must be a basi
problem).

Here is a sample of the code I am using:

Private Sub EnterInfo_Click()

If txtStaff.Text = "" Then
MsgBox "Please enter number of staff", 64, "Error Message"
CloseButton.Locked = True
CloseButton.BackColor = &H80000013
txtStaff.BackColor = &H80000013

Else
If txtStaff >= 0 Then
CloseButton.Locked = False
CloseButton.BackColor = &H80000010
txtStaff.BackColor = &H80000005


Any help much appreciated

Cheers

Peter (new to VBA

--
peter.thompso
-----------------------------------------------------------------------
peter.thompson's Profile: http://www.hide-link.com/ ;userid=2968
View this thread: http://www.hide-link.com/

Excel60  
 
 
Leith





PostPosted: Tue Dec 27 14:23:59 CST 2005 Top

Excel Programming >> Textbox highlighting issue
Hello Peter,

You just set the focus back on the TextBox. See your code below. Th
method is in bold type.

Private Sub EnterInfo_Click()

If txtStaff.Text = "" Then
MsgBox "Please enter number of staff", 64, "Error Message"
CloseButton.Locked = True
CloseButton.BackColor = &H80000013
txtStaff.BackColor = &H80000013
TXTSTAFF.SETFOCU

Else
If txtStaff >= 0 Then
CloseButton.Locked = False
CloseButton.BackColor = &H80000010
txtStaff.BackColor = &H80000005

Sincerely,
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=49624

 
 
peter





PostPosted: Tue Dec 27 14:29:31 CST 2005 Top

Excel Programming >> Textbox highlighting issue
Thanks Leith - steep learning curve this VBA!

Cheers

Pete

--
peter.thompso
-----------------------------------------------------------------------
peter.thompson's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=2968
View this thread: http://www.excelforum.com/showthread.php?threadid=49624