Solved

add new record on a other open form with vba on microsoft access 2013

Posted on 2014-02-11
3
3,375 Views
Last Modified: 2014-02-12
hi

i can two forms open for expamle the names are form1 and form2

and i wan't when i press on some button in form2 it's will set the focus on form1 in a new record by the field form1!Id

something like this

 
        DoCmd.GoToRecord (on form1) , , acNewRec
        DoCmd.GoToControl ("form1!InvoiceNum")
0
Comment
Question by:bill201
  • 2
3 Comments
 
LVL 19

Expert Comment

by:MINDSUPERB
ID: 39852430
Hello Bill201,

Try these codes:

DoCmd.GoToRecord acDataForm, "form1", acNewRec
Forms!form1.SetFocus
Forms!form1!InvoiceNum.SetFocus

Sincerely,

Ed
0
 

Author Comment

by:bill201
ID: 39852467
thanks alot for your answer but i get an error message after the first line (it's a sub form so it's look like this :

DoCmd.GoToRecord acDataForm, "Forms!form1parent!form1child.Form", acNewRec

and i get an error message like this "run time error 2489 the object "Forms!form1parent!form1child.Form" isn't open. But the form is actually open, so what is going on there?
0
 
LVL 19

Accepted Solution

by:
MINDSUPERB earned 500 total points
ID: 39852490
Try to use these instead:

Forms!form1.SetFocus
Forms!form1!form1child.SetFocus
DoCmd.GoToRecord , , acNewRec

Ed
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
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.

679 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