473,416 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Populating Table With Calculated Report Values

Here are the relevant "givens" to my problem...

Form: frmLaunchRpt
- Text Box: txtAsOfDate
- Check Box: chkLogEval
- Command Button: cmdLaunchRpt

Report: rptEvaluation
- Text Box: txtGreen (Percent of items on schedule)
- Text Box: txtYellow (Percent of items slightly off schedule)
- Text Box: txtRed (Percent of items greatly off schedule)

Here is a sample of what information I want to output and store on a
table...

Table: tblLogEvaluation

[Date] [Green] [Yellow] [Red]
txtAsOfDate(1) txtGreen(1) txtYellow(1) txtRed(1)
txtAsOfDate(2) txtGreen(2) txtYellow(2) txtRed(2)
txtAsOfDate(3) txtGreen(3) txtYellow(3) txtRed(3)
..
..
..
txtAsOfDate(n) txtGreen(n) txtYellow(n) txtRed(n)

The problem...

I have a percentage calculation in the report footer of my
"rptEvaluation" report. The information in the footer of the report
needs to be logged to a table, but not every time the report is run.

To accomplish this, the user will have a check-box selection called
"chkLogEval" on a form (frmLaunchRpt) that launches rptEvaluation. So
the information in rptEvaluation will ONLY be logged to a table when
the condition chkLogEval = TRUE. The user presses the launch button
(cmdLaunchRpt) to open the report.

The Solution...

I want to write a VBA script under the "On Open" property of
rptEvaluation to check to see if chkLogEval = TRUE. If it is, then it
will append an entry to tblLogEvaluation, retrieving the fields shown
in the sample table.

Please assist me with the proper coding to solve this problem.
Thanks in advance.

Nov 13 '05 #1
1 2469
Greetings,

You won't be able to retrieve the calculated value from the Report Open
event because that is where the calculation is taking place. You can
retrieve the calculated result in the Detail Event. Note: If you have
several records but only one calculated result, you may want to add a
boolean flag so that you don't keep retrieving the same value.

You can use basic sql to retrieve the value in the Detail Event like
this:

Dim bGetData 'declare boolean var at module level of report

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If bGetData = True Then
if Forms!frmLaunchRpt!chkLogEval = True Then
DoCmd.RunSql "Update tblLog Set PercentVal = " & txtPercent
bGetData = False
End If
End If
End Sub

Private Sub Report_Open(Cancel As Integer)
bGetData = True 'set boolean var to true here
End Sub

This code assumes that the Table field (PercentVal from tblLog) which
will receive the value from the report is a numeric field and thus does
not require delimiting with single quotes like a string value would when
using Sql.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Sidney Linkers | last post by:
Hi, I'm trying to make a calculated text field in a query where the textvalue is being populated from multiple records. I already use a VBA function to loop through records and concatenate the...
3
by: ssb | last post by:
Hello, This may be very elementary, but, need help because I am new to access programming. (1) Say, I have a column EMPLOYEE_NAME. How do I fetch (maybe, cursor ?) the values one by one and...
1
by: tconway | last post by:
I have an Access program that displays Customer data into a form and OrderID data into a subform. The totals in the Subform are based on calculated fields, i.e. the Total Amount field Calculates...
3
by: otac0n | last post by:
How can I select the maximum value from a field, but make sure that the value i want stays greater than a cetrain value? I currently have this: SELECT A.rating, B.rating,...
18
by: TORQUE | last post by:
Hi, Im wondering if anyone can help me with a problem. I have a form with more than 50 unbound fields. Some of the fields will be blank from time to time. This seems to be where im having...
9
by: Mohd Al Junaibi | last post by:
Hello all, my first post here...hope it goes well. I'm currently working on stored procedure where I translated some reporting language into T-SQL The logic: I have a group of tables...
8
by: Gilberto | last post by:
Hello, I have created a query to help me calculate some total values i need for a report. In the query field i have the following: TCL1: Costing!*(Engineering!+Engineering!) The results...
3
by: Connell | last post by:
I have an Access 2003 report that has multiple calculated values. Now I need to use one of those values in a subform. Is there a technique in Access similar to SetValue so a calculated report...
5
by: royals | last post by:
Hello Access gurus, I am a self-taught Access “developer” and have a ton to learn so please allow me to sound stupid. I am using 2003 on a XP platform. I manage properties for an...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.