Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2014-02-11
3
Medium Priority
?
3,534 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 2000 total points
ID: 39852490
Try to use these instead:

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

Ed
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

877 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