?
Solved

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

Posted on 2010-04-06
15
Medium Priority
?
420 Views
Last Modified: 2012-05-09
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
0
Comment
Question by:quizzer
  • 8
  • 6
15 Comments
 
LVL 75
ID: 29930278
Comment out the On Error Resume Next line and see what the Error is.

mx

0
 
LVL 75
ID: 29932208
Also, try setting the Focus to a specific control on the form:

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

mx
0
 

Author Comment

by:quizzer
ID: 29932804
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
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 

Author Comment

by:quizzer
ID: 29933056
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
0
 
LVL 75
ID: 29933243
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
0
 

Author Comment

by:quizzer
ID: 29938162
The focus goes nowhere that's the problem there is no focus set anywhere
0
 
LVL 75
ID: 29938493
ok ... did you try the syntax I posted ?

mx
0
 

Author Comment

by:quizzer
ID: 29938862
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
0
 
LVL 75
ID: 29939753
ok ... are you *positive* that no code is running when this form opens ... such that the focus gets moved ?

mx
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 200 total points
ID: 29939922
Meanwhile ... let try this:

    DoCmd.OpenForm "Frm_Claimant", acNormal, "", "", , acNormal
    DoCmd.GoToRecord acForm, "Frm_Claimant", acNewRec
    With Form_Frm_Claimant
        .Txt_Claimant_Last_Name.SetFocus
    End With
   
     'Forms("Frm_Claimant")("Txt_Claimant_Last_Name").SetFocus   ' Comment out

mx
0
 

Author Comment

by:quizzer
ID: 29939997
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.
0
 

Author Comment

by:quizzer
ID: 29942151
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
0
 
LVL 75
ID: 29943091
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
0
 
LVL 6

Expert Comment

by:JVWC
ID: 29994059
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
0
 
LVL 75
ID: 30036653
btw ... I emulated your exact situation in A2003, same names etc., and the focus was set.

mx
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

589 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question