If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Visual Basic > VBA help... How to stay on current textbox

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-29-11, 10:41
hsiddique hsiddique is offline
Registered User
 
Join Date: Dec 2011
Posts: 3
VBA help... How to stay on current textbox

Hi all,

I have a textbox that checks where the value entered (in this case Year) is in the past, present or future.

If it is in the past a msgbox appears, The users will click OK, but the cursor goes to the next textbox, rather then staying on the textbox that needs to be corrected.

Any ideas on how to stay on the textbox?

Thanks

Halil
Reply With Quote
  #2 (permalink)  
Old 12-29-11, 11:07
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,264
use the setfocus function in the code that handles the message box.
alternatively redesign your code to include a date picker that doesn't allow the users to choose an invalid date
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 12-29-11, 11:26
hsiddique hsiddique is offline
Registered User
 
Join Date: Dec 2011
Posts: 3
Hi,

I've added it but still no go

Code:
            If txtStartDate.Text < iYear Then
                MsgBox "Please enter a year that is not in the past", vbCritical, "Please enter Year..."
                frmCityDev.txtStartDate.SetFocus

            End If
It still goes to the next textbox.
Reply With Quote
Reply

Tags
textbox, vba

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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