Solved

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

Posted on 2014-02-11
3
3,296 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

762 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

24 Experts available now in Live!

Get 1:1 Help Now