Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to save from calculated fields in a report to table

Status
Not open for further replies.

2access

Technical User
Sep 14, 2006
2
AU
Hi everyone, I have three calculated fields of Tax, Gross pay and Netpay in the detail section of my payslip report which I need to be saved in a table named PrMDetails. I need a button on my payroll form to get a primary code corresponding to that employee and save all these data in the PrMdetails table, whenever I click it.
Could anyone please help me with this problem?
 
You shouldn't normally store calculated values. You certainly shouldn't use anything around a report to save values. If you need to create and save values, do it with code or events in a form and then just report the values afterward.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Thanks for you replay.
I am not very good at codes and I used only Access features to get in here. I needed to use the report because I needed to create a payslip print out for different employees who work on a casual basis. In this way I was able to calculate tax as well. Now I need a way to save Tax and Gross pay in a table. Please let me know if there is a better way aroundthat.
 
If you can calculate something in a report, you should be able to calculate it outside a report. Then print your report.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
you could use the report page event and me.textboxvalue to get the textbox value and then append it to a table using
strsql = "INSERT INTO table (field) values (" & textboxvalue & ")"
DoCmd.RunSQL strsql

Ian Mayor (UK)
Program Error
Programming is 1% coding, 50% error checking and 49% sweat as your application bombs out in front of the client.
 
I would like to do something similar to what is discussed above. However, if I do txtBox9.value, I don't get the contents of the textbox, instead I get an error "Runtime error 2427. You entered an expression that has no value".
I am trying to put the code in the report_open event. Thanks.
 
My opinion is don't go there. If you really want to, you can't generally grab any values from controls in the Report Open event. Values from controls can be best retrieved in the On Print event of the section containing the controls.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
I agree with dhookom, rather not store calculated values in tables, because it is a waste of space.

If your really want to, and there some circumstances thinkable, have a look at append query's. You can f.i. create a table like tblPaidSalary, and append records to this table with an append query (the same query as you use for your report, but then appending it to a table.) You can run for example the query at the same moment you print your salary slips.

Pampers [afro]
Keeping it simple can be complicated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top