|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Lost_Focus event of controls doesn't fireIn my form there is one Combo box, text box and Command button. Command button's caption is "&Save". I have also given a hot key "F9" to the button. In the lost focus event of Combo & text boxes I am validating the values given from the respective controls. When I click Save button using mouse, the lost focus event of the controls fires and the validation is done properly. But When I press F9 or ALT+S to save the details, the lost focus event of the controls doesn't fire and the validation is not done. In the Form_KeyDown event I trapped F9 key and found the Active Control and called the Lost_Focus event of the active control and did the validation. But I could not trap ALT+S to the validation. Please give a solution to solve this scenario. Regards, M. Abdhul Saleem. "Abdhul Saleem" <AbdhulSal***@discussions.microsoft.com>'s wild thoughts were released on Fri, 21 Oct 2005 06:09:02-0700 bearing the following fruit: >Hi, That's an unrliable and user unfriendly way of doing> >In my form there is one Combo box, text box and Command button. > >Command button's caption is "&Save". I have also given a hot key "F9" to the >button. > >In the lost focus event of Combo & text boxes I am validating the values >given from the respective controls. validation. >When I click Save button using mouse, This is the point where I would do my validation.>the lost focus event of the controls Some of the time....>fires and the validation is done properly. >But When I press F9 or ALT+S to save the details, the lost focus event of That's why MS added a validate event in VB6, just take my>the controls doesn't fire and the validation is not done. advice and write a validation routine that you call when the user clicks save. Jan Hyde (VB MVP) -- If you have a lot of tension and you get a headache, do what it says on the aspirin bottle: Take two and keep away from children. (Barbie Jo) [Abolish the TV Licence - http://www.tvlicensing.biz/]
Show quote
Hide quote
"Abdhul Saleem" <AbdhulSal***@discussions.microsoft.com> wrote in message Have you experimented with the Validate event? You can force that to fire, news:2CC0EAC9-45C4-4418-A7A6-60AFE55649B9@microsoft.com... > Hi, > > When I click Save button using mouse, the lost focus event of the controls > fires and the validation is done properly. > > But When I press F9 or ALT+S to save the details, the lost focus event of > the controls doesn't fire and the validation is not done. > > But I could not trap ALT+S to the validation. > > Please give a solution to solve this scenario. > > Regards, > M. Abdhul Saleem. regardless of which control has focus by calling the ValidateControls method.... This needs a new project with a couple of textboxes and a command button. '============= Option Explicit Private Sub Command1_Click() 'this could be the Save button ValidateControls End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) On Error Resume Next ValidateControls If Err.Number <> 0 Then Cancel = True End If Err.Clear End Sub Private Sub Text1_Validate(Cancel As Boolean) If Text1.Text <> "Valid" Then MsgBox "Text1 contents not valid" Cancel = True End If End Sub Private Sub Text2_Validate(Cancel As Boolean) If Text2.Text <> "Valid" Then MsgBox "Text2 contents not valid" Cancel = True End If End Sub '============= Another way is to validate all controls when the user hits Save. That's actually better imo. Let the user type whatever they want and tell them where they went wrong before saving. -- Ken Halter - MS-MVP-VB - http://www.vbsight.com DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm Please keep all discussions in the groups.. "Ken Halter" wrote: I always preferred the "validate-as-you-go" myself. I thought it annoying > > Another way is to validate all controls when the user hits Save. That's > actually better imo. Let the user type whatever they want and tell them > where they went wrong before saving. > to hit Save, get the "fix this" message, hit Save again, get the "now fix that", etc., especially when the choices further down the form depend on what's been entered prior. But it really depends on the application. "Charlie" <Char***@discussions.microsoft.com>'s wild thoughts were released on Fri, 21 Oct 2005 08:17:03 -0700bearing the following fruit: > Your a mouse user.>"Ken Halter" wrote: > >> >> Another way is to validate all controls when the user hits Save. That's >> actually better imo. Let the user type whatever they want and tell them >> where they went wrong before saving. >> > >I always preferred the "validate-as-you-go" myself. I thought it annoying >to hit Save, get the "fix this" message, hit Save again, get the "now fix >that", etc., especially when the choices further down the form depend on >what's been entered prior. But it really depends on the application. Jan Hyde (VB MVP) -- The man who invented the Hokey-Pokey died over a month ago, but the undertaker is still trying to get him into the coffin. He puts his right foot in..." [Abolish the TV Licence - http://www.tvlicensing.biz/]
Hex--->Dec!
Extract ole object using vb from access db Intergating Multiple VB6.0 Projects into one: Project Grouping Parsing UNIX text files Return an error code/message from a VB6 app Is this possible ? Intercept the Min/Max button Press Error 453: Can't find DLL entry point (VB6) Launching App Order of forms |
|||||||||||||||||||||||