Link to home
Start Free TrialLog in
Avatar of quizzer
quizzer

asked on

Set Focus Not Working in Access 2007 Opening Form go To New Record

I honestly cannot believe this
Simple Code on a Double Click of a Comb Box.  Used it for Years and Works fine in Access 2003

On Error Resume Next
    DoCmd.OpenForm "Frm_Claimant", acNormal, "", "", , acNormal
   
    DoCmd.GoToRecord acForm, "Frm_Claimant", acNewRec
    Forms!Frm_Claimant!Txt_Claimant_Last_Name.SetFocus
   

No matter what I do in Access 2007 it WILL NOT set focus on Txt_Claimant_Last_Name on the new record.

How can I fix this?  Thanks
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Comment out the On Error Resume Next line and see what the Error is.

mx

Also, try setting the Focus to a specific control on the form:

Forms("Frm_Claimant!Txt_Claimant_Last_Name")("SomeControlName").SetFocus

mx
Avatar of quizzer
quizzer

ASKER

This is just Access 2007 opening a .mdb file.  All other functionality works perfectly

I remarked out the On Error Resume Next

Set the module options to break on all errors.  Ran it nothing happened no error and still no cursor in the Text Box Txt_Claimant_Last_Name


Txt_Claimant_Last_Name is a specific control on the form
Avatar of quizzer

ASKER

That is what is so weird No Error, Works Perfectly Fine in Access 2003, but no matter what I do

Go To Control, Set Focus Nothing Works when used in Access 2007
oops ... I missed the control name in my previous post - ignore that:

Try this syntax

Forms("Frm_Claimant")("Txt_Claimant_Last_Name").SetFocus

btw ... where DOES the focus go ?

And better set back to Break On Unhandled Errors.

mx
Avatar of quizzer

ASKER

The focus goes nowhere that's the problem there is no focus set anywhere
ok ... did you try the syntax I posted ?

mx
Avatar of quizzer

ASKER

Once again set it to break on all errors
used this Below
No Error and again no cursor in the Txt_Claimant_Last_Name with Access 2007
Works fine in Access 2003


    DoCmd.OpenForm "Frm_Claimant", acNormal, "", "", , acNormal
   
    DoCmd.GoToRecord acForm, "Frm_Claimant", acNewRec
   Forms("Frm_Claimant")("Txt_Claimant_Last_Name").SetFocus
ok ... are you *positive* that no code is running when this form opens ... such that the focus gets moved ?

mx
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of quizzer

ASKER

Yes this is a procedure we use all the time to double-click the combo box open a new form on a new record at a specific control.  For some reason Access 2007 is cauing issues.
Avatar of quizzer

ASKER

Tried this as well.  Same result no focus set


    DoCmd.OpenForm "Frm_Claimant", acNormal, "", "", , acNormal
    DoCmd.GoToRecord acForm, "Frm_Claimant", acNewRec
    With Form_Frm_Claimant
        .Txt_Claimant_Last_Name.SetFocus
    End With
Well ... just for kicks, can you convert to A2003 and upload?
Compact & Repair first, then Zip to reduce size.  Remove any sensitive data.

Kind of out of ideas ...

mx
MX
If it works in A03 as suggested I'll take a peek in A07. Let me know.

Quizzer, just a thought...
Have you tried setting the focus to another control to see if that works.Perhaps there is a reason that control cannot accept the focus.
Perhaps a msgbox as the last line will let you know if the code is actually running.
JC
btw ... I emulated your exact situation in A2003, same names etc., and the focus was set.

mx