Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

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
?
251 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

721 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