Set Focus back on field (Access 2000 form) 
Author Message
 Set Focus back on field (Access 2000 form)

Hello,

I hope my problem is addressed correctly in this newsgroup.

Form_Reclaims subform - 1

Option Compare Database

Private Sub DocQuant_LostFocus ()
If DocQuant <=0 Then
    MsgBox ("Please enter a valid document quantity")
DocQuant.SetFocus
End If
End Sub

What I would like: Set the focus back to field "DocQuant", but the above
code doesn't do that. Although DocQuant.SetFocus, focus moves into the next
field. I want the focus to be remain on the DocQuant field, unless a value

Quote:
>0 has been inserted.

Thank you for your help

Pasquale Imbemba



Mon, 12 Jan 2004 16:41:48 GMT  
 Set Focus back on field (Access 2000 form)
You cannot set the focus to a control while the focus is in the process
of leaving that same control.

Try adding a hidden control of any type on the form. Add code to its
GetFocus event to return the focus to the 'DocQuant' control. Change
your existing code in the 'DocQuant' control to send the focus to the
new control.

What you'll get is:
    on leaving DocQuant, the focus is passed to the new control
    on entering the new control, the focus is passed to DocQuant.

HTH,
--

    National Library of Canada
 -- Nothing in the above should be construed to represent
    anything other than my own opinions and personal reality. --


Quote:
> Hello,

> I hope my problem is addressed correctly in this newsgroup.

> Form_Reclaims subform - 1

> Option Compare Database

> Private Sub DocQuant_LostFocus ()
> If DocQuant <=0 Then
>     MsgBox ("Please enter a valid document quantity")
> DocQuant.SetFocus
> End If
> End Sub

> What I would like: Set the focus back to field "DocQuant", but the
above
> code doesn't do that. Although DocQuant.SetFocus, focus moves into the
next
> field. I want the focus to be remain on the DocQuant field, unless a
value
> >0 has been inserted.

> Thank you for your help

> Pasquale Imbemba



Mon, 12 Jan 2004 21:21:38 GMT  
 Set Focus back on field (Access 2000 form)
This is just a timing error.  The lostfocus event fires before the
cursor actually moves to the new field, after it fires the cursor then
moves.  You should probably use the AfterUpdate Event.  I have, in a
few cases, resorted to placing this type of validation in the GotFocus
of the gaining control.
Quote:

> Hello,

> I hope my problem is addressed correctly in this newsgroup.

> Form_Reclaims subform - 1

> Option Compare Database

> Private Sub DocQuant_LostFocus ()
> If DocQuant <=0 Then
>     MsgBox ("Please enter a valid document quantity")
> DocQuant.SetFocus
> End If
> End Sub

> What I would like: Set the focus back to field "DocQuant", but the above
> code doesn't do that. Although DocQuant.SetFocus, focus moves into the next
> field. I want the focus to be remain on the DocQuant field, unless a value
> >0 has been inserted.

> Thank you for your help

> Pasquale Imbemba



Mon, 12 Jan 2004 21:31:18 GMT  
 Set Focus back on field (Access 2000 form)
Use the Exit Event instead.  Also, it is better to use fully qualified
references.

***Code not test***
Private Sub DocQuant_Exit(Cancel As Integer)
    If Me.DocQuant <=0 Then
        MsgBox ("Please enter a valid document quantity")
        Cancel = True
    End If
End Sub
***Code ends***

HTH
Van T. Dinh


Quote:
> Hello,

> I hope my problem is addressed correctly in this newsgroup.

> Form_Reclaims subform - 1

> Option Compare Database

> Private Sub DocQuant_LostFocus ()
> If DocQuant <=0 Then
>     MsgBox ("Please enter a valid document quantity")
> DocQuant.SetFocus
> End If
> End Sub

> What I would like: Set the focus back to field "DocQuant", but the above
> code doesn't do that. Although DocQuant.SetFocus, focus moves into the
next
> field. I want the focus to be remain on the DocQuant field, unless a value
> >0 has been inserted.

> Thank you for your help

> Pasquale Imbemba



Tue, 13 Jan 2004 08:56:08 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. passing forms and controls so I can set focus back to a form from a module

2. passing forms and controls so I can set focus back to a form from a module

3. Setting focus back to a text field

4. Setting focus back to MDI-form

5. set focus back to access after automation

6. Setting Field Properties in Access 2000 possible?

7. setting focus on a form field?

8. How to Set Focus to a Form Field

9. Getting back the formatted MsgBox in Access 2000 that worked in Access 97

10. Access 2000 back to Access 97

11. Access 2000 back to Access 97

12. Setting focus back after entering carrige return

 

 
Powered by phpBB® Forum Software