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
245 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 5

Accepted Solution

by:
noetymology earned 125 total points
Comment Utility
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
Comment Utility
Thank you for your efforts.
0
 
LVL 5

Expert Comment

by:noetymology
Comment Utility
You are very welcome. Good luck!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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.

763 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

8 Experts available now in Live!

Get 1:1 Help Now