Solved

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

Posted on 2002-05-30
3
3,055 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
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…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

617 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