Solved

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

Posted on 2002-05-30
3
2,986 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

821 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