Set focus for new record

Posted on 2013-10-01
Medium Priority
Last Modified: 2013-10-01
When my form opens for a new record I'm trying to set focus on a particular textbox.  Here's my code which isn't working...

Private Sub Form_Open(Cancel As Integer)

    If Me.NewRecord = True Then
    End If

End Sub


Question by:SteveL13
  • 2

Expert Comment

ID: 39536549
I think this is simply a timing issue.  You don't mention an error message and I just did a little test and found that there is no error message when you run code like yours... it just doesn't work.  I believe it's because those fields aren't actually available yet, but it's hard to be sure.

What I do know is that type of scenario works fine for me in the _Load event.  I think the end result should be the same so try it out and let us know how it goes.
LVL 53

Accepted Solution

Gustav Brock earned 2000 total points
ID: 39536619
Move it to the OnCurrent event.

LVL 50

Expert Comment

by:Dale Fye
ID: 39536708
No points.  Agree with gustav.  Generally, if you want to work with a particular record, you should use the Current event.

Expert Comment

ID: 39536733
I just suggested _Load because the first four words in the post are "When my form opens".

If he is using the form in a scenario where he's moving between records and potentially getting to a new record that way, then I totally agree that the Current event is more appropriate.

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
What to do if a split doesn't fit? Or a bunch of invoice lines must be rounded while the sum must match a total? It takes a little, but - when done - it is extremely easy to implement.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…

621 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