Solved

Keep Focus On the Specific TextBox

Posted on 2008-06-11
3
168 Views
Last Modified: 2010-04-30
When the user fill the Textbox I want to check his information with the data base if is found I want to tell him Record found before then cancel the lostfocus . Where I can apply this code and how to to that
0
Comment
Question by:Ahmadal_najjar2003
3 Comments
 
LVL 16

Accepted Solution

by:
robinu earned 250 total points
ID: 21766478
In VB6, you can use the Textbox' Validate event.

e.g.:
The function CheckedInDatabase() should check the information in the database, and return True when ok,
and False when not ok.
Private Sub Text1_Validate(Cancel As Boolean)

    'check in database    

    If Not CheckedInDatabase(Text1.Text) Then

        Call MsgBox("Sorry, not found in database")

        Cancel = True

    End If

End Sub

Open in new window

0
 
LVL 69

Assisted Solution

by:Éric Moreau
Éric Moreau earned 250 total points
ID: 21767610
Be sure to set the CausesValidation to False on your Cancel or Exit button otherwise the user won't be even able to close the form.
0
 

Author Closing Comment

by:Ahmadal_najjar2003
ID: 31466436
Thanks A lot
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now