Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validate Event on current control

Status
Not open for further replies.

Lemox

Programmer
Dec 13, 2003
67
GB
Hi there,

I would like to know how to run current control's Validate Event before performing a treatment.
For example, I have to check several textboxes containing dates before clicking on a button that starts a SQL query.
The problem is that my "OK" button has its Default property set to True : so, no event related to the current control is started (nor Validate, neither LostFocus) when I push on Enter.
Globally, how could I write the magic instruction "MyForm.ActiveControl_Validate" ?

Thanks !
Lemox
Lemox
 
With the information that you gave one of the two solutions below might work for you:

1) I would personally validate all text box dates in the cmdOK_click event. If they validate ok then continue with your code to run you SQL. If one of them doesn't validate ok then skip the SQL code and give a message about which one is not correct.

2) Basically it's the same concept as #1 but you acutally put the testing code in the Text1_Validate event and explicitly call that event within the cmdOk_click event. The explicit call would be something like Call Text1_Validate(False).

Hope this was what you were looking for,
CA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top