AboutRichard Rost Expertise I can answer any questions pertaining to Microsoft Visual Basic 6.0, Microsoft Access VBA, and the Visual Basic Language in general. I do NOT use VB.NET or VB 2005/08 much yet, so don't ask me any questions specific to those. Also, please feel free to check the Tips & Tricks section of my web site for VB tips.
Education/Credentials I am a self-taught VB expert. I have been building software for clients since the early 90s (and on my own since I was a child). You can see a sample of my Tutorials on my web site at 599CD.com
Expert: Richard Rost Date: 6/15/2008 Subject: facing problem in LostFocus property of textbox
Question Dear Sir,
First many many thanks for your previous valuable suggestion,
Sir here i am doing a validation with a text box that,There is a text box in the form.The validation i need that when i will add new data it will check from database if the data is exists then it show a message that the value is exist and prompt back to the textbox.
For this i wrote please check it...
--------------------------------------------
Private Sub vn_txt_LostFocus()
If rs.Fields("VesselName") = vn_txt.Text Then
MsgBox "VesselName Already exists Please Enter a Different VesselName", vbExclamation, "VesselName"
vn_txt.SetFocus
End If
End Sub
------------------------------------------------
in run time when i click any buttom like next ,previous... this message appears.while i am setting the textbox's tabstop property false then it works but not check the validation. my target is that while i will add new data to the text box then only it check the validation. please check the code and suggest me to solve the above problem.
Thanking u
Bipan
Answer Compare the value that the box had BEFORE you tabbed to it with the value as you're leaving. If they're different, assume the user changed the value and then run your code. Otherwise, it's just a TAB through, and don't run it.
Let me know if you have any other questions or comments.
P.P.S. I volunteer my time at AllExperts to help people, and I get a LOT of questions, so I can't take an hour to answer each question. If you need more DETAILED HELP, come to my TechHelp web site at http://www.599cd.com/TechHelp/AllExperts and I'll take as much time as you need to answer your question.