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

x
?
Solved

How do I run a Macro in Access 2007 each time a new record is added to the database

Posted on 2009-05-15
6
Medium Priority
?
255 Views
Last Modified: 2013-11-27
Hello,

I'm in the process of designing an Access database for a reservation system.  I have a Java front end that allows data entry into the database, but would like to have a confirmation report printed each time a new record is added.  I know that one of the options when creating macros in Access is to print a report, but I'm not sure what condition to use so that the macro is run every time a new record is added.  Also, I want the report to use the most recent information in the report.  Any help would be great.

Thanks,

Raymond Northcott
0
Comment
Question by:rnorthcott
  • 4
  • 2
6 Comments
 
LVL 5

Expert Comment

by:noetymology
ID: 24398923
I would create a form for only data entry. On the On Close event of the form, i would use the following code
DoCmd.Save , acForm, "frmCustomers"
DoCmd.OpenReport "rptCustomers", acViewReport, "", "", acNormal
DoCmd.PrintOut acPrintAll, , , acHigh, 1, True
DoCmd.Close acReport, "rptCustomers"
I would filter my report based on the data present on the data entry form. For eg, i entered a record for Customer No. 15, On closing the form, it is ensure that the data is saved, then report will be generated for only Customer No. 15, printed and then closed immediate, so that the user doesnt notice that it had been opened.
0
 
LVL 5

Expert Comment

by:noetymology
ID: 24398954
There could also be other  methods like having a button on the form to print the report. Instead of VBA you can also use a macro do to the same. Also instead of having to click a button , you can also put the VBA/macro in the Lost Focus event of the textbox that you would enter data to at the last. This way once the data is entered and you press tab key, the last control would lose its focus and report would be printed, however this method can have problems as if someone puts the focus and then moves out from that last text box then it would fire that VBA/macro and an incomplete report may get printed
0
 

Author Comment

by:rnorthcott
ID: 24399010
Is there a way to do this without using a form?  I'm hoping that the end user will only have to run my java front end to do the data entry, instead of a form in access.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Accepted Solution

by:
noetymology earned 375 total points
ID: 24399058
Sorry but my expertise are not with Java however i found this for you if it can help. As shown here, you can create a VB script and call it in your Java app. Replace the Excel Application with Access and call the macro created in Access that would print your report. http://www.egjug.org/call_excel_macro_from_java
0
 

Author Closing Comment

by:rnorthcott
ID: 31582063
Thank you for your efforts.
0
 
LVL 5

Expert Comment

by:noetymology
ID: 24399105
You are very welcome. Good luck!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
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…
Suggested Courses

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