Unanswered: Checking parameter values against report values
Hi basically what I have is a hard copy master report with totals on it and I'd like to print off other reports based on the totals in the master. I'm trying to automate it so that a report will only print if the total matches the corresponding total in the master report.
I was thinking firstly of creating a form where the user can type in the totals and they can be stored in a table. What I then need is a way to match the inputted totals with the totals in the reports.
Firstly, is there a way to do this? Say I have a form called input_form, the user types values into here and are stored in input_table. I want to check the total value in report1 against the total value for the corresponding field in input_table.
Give something like this a try....Place the following code into the OnFormat event located within the Details section of your report. For Example:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim dbs As Database
Dim rst As Recordset
On Error Resume Next
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("input_table")
If Err Then GoTo NoRecds
Do Until rst.EOF
If Me.reportRecordIDField = rst!tableRecordID Then
If Me.reportTOTALVALUE <> rst!tableTotalValue Then
MsgBox "TOTALS ERROR:@@" & "Report total does not match up. " & _
"Please check Data.", vbExclamation, "Totals Error"
Set dbs = Nothing