Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't use the GoToRecord action or method on an object in Design view. 1

Status
Not open for further replies.

rokerij

Technical User
Feb 12, 2003
199
I am trying to access a record on a form, but once the code tries to execute the line:

DoCmd.GoToRecord , , acNewRec

I get a run-time error that reads, "You can't use the GoToRecord action or method on an object in Design view." My form is clearly NOT in design view, so I really don't know what this message is all about. Thanks for the help.
 
Perhaps it isn't your form that the message is referring to. When you leave out the first two arguments of GoToRecord, the "active" object (the object that currently has the focus, or the object selected in the Database Window) is assumed. Often, when you're developing the database and especially if you're stepping through code, the active object will be something other than what it would be when running on the user's PC. For example, you might have the focus on a code module window, the Database Window, or the Debug/Immediate window. Since these "objects" don't have recordset data in them, you could get this message.

If the GoToRecord call is in the form where you want to change records (it typically is), try providing explicit arguments, such as:
Code:
    DoCmd.GoToRecord acForm, Me.Name, acNewRec

Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top