Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

920 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

16 Experts available now in Live!

Get 1:1 Help Now