Solved

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

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

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…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
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…
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…

810 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