Solved

Help! DoCmd.GoToRecord , acDataForm, acNewRec??  doesn't work

Posted on 2002-05-30
3
2,911 Views
Last Modified: 2008-03-10
I am trying to enter a new record. The code I have written overwrites an existing record (not good). How do I enter a new record in code. I am using

'open the form to access it
        DoCmd.OpenForm "frmmaintenance", acNormal, , , acFormAdd, acWindowNormal
       
        'Make new record
         Form_frmMaintenanceSub.Customer.SetFocus
         DoCmd.GoToRecord , acDataForm, acLast
         DoCmd.GoToRecord , acDataForm, acNewRec ??
'Setfocus on text box then write to it
        Form_frmMaintenanceSub.Customer.SetFocus
        Form_frmMaintenanceSub.Customer.Text = Me.txtCustname
        Form_frmMaintenanceSub.Request.SetFocus
        Form_frmMaintenanceSub.Request.Text = Me.description
        Form_frmMaintenanceSub.Priority.SetFocus
        Form_frmMaintenanceSub.Priority.Text = "Z - Non Proritised"

Any suggestions please
0
Comment
Question by:HPD
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
James Elliott earned 200 total points
ID: 7044062
DoCmd.GoToRecord , , acNewRec
0
 
LVL 12

Expert Comment

by:James Elliott
ID: 7044072
So.

DoCmd.OpenForm "frmmaintenance"
DoCmd.GoToRecord , , acNewRec

With Form_frmMaintenanceSub
 .Customer.SetFocus
 .Customer.Text = Me.txtCustname
 .Request.SetFocus
 .Request.Text = Me.description
 .Priority.SetFocus
 .Priority.Text = "Z - Non Proritised"
End with

0
 

Author Comment

by:HPD
ID: 7045681
jell it now displays an error "Run time error '2105' you can't go to the specified record"
 I can go to the form "maintenance" (and subform "submaintenance")and use the standard menu bar to enter a new record but I need to be able to do it in code.

0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now