ralphralph07
MIS
Hi
I have a report that worked fine in a previous version but since updating no longer prints the required record.
I've tried reviewing the code below but I can't seem to find how it sets which record to print? What i ideally need is to replace the current code to prompt the user for the labRef rather than access doing it automatically?
I've tried setting a parameter on the Result Parameter Query but this hasn't helped.
I've looked the parameterquery but i cant find this in the database?
I have a report that worked fine in a previous version but since updating no longer prints the required record.
I've tried reviewing the code below but I can't seem to find how it sets which record to print? What i ideally need is to replace the current code to prompt the user for the labRef rather than access doing it automatically?
I've tried setting a parameter on the Result Parameter Query but this hasn't helped.
I've looked the parameterquery but i cant find this in the database?
Code:
Sub print_analysis(LabREF As String, Site As String, suite As String, stype As String, repname As String, Parameterquery)
' This routine sets all of the test parameters used in suites to
' invisible, then resets those used by the suite to visible.
'********* SET VARIABLE AND PARAMETERS *****************
Dim mydb As Database, st As Recordset, res As Recordset, testname As String
Dim myc As Control, tgrp As String, resgrp As String, mysql As String
Dim current_group As String, lab_ref As String
Dim equivalence As String, testvalue As Double
Dim testuom As String, comments As String, print_pos As Integer
Set mydb = CurrentDb()
Set st = mydb.OpenRecordset(Parameterquery)
Set res = mydb.OpenRecordset("Results Parameters")
'********** PREPARE REPORT TITLE *******************
Call prepare_title(repname, stype, Site)
'*********** SET BOXES TO "M" AND MAKE INVISIBLE ***********
For j = 1 To 44
Reports(r_name)("box" + Str$(j)).Visible = False
Reports(r_name)("box" + Str$(j)).Caption = "M"
Reports(r_name)("eq" + Str$(j)).Visible = False
Reports(r_name)("eq" + Str$(j)).Caption = "M"
Reports(r_name)("val" + Str$(j)).Visible = False
Reports(r_name)("val" + Str$(j)).Value = "M"
Reports(r_name)("uom" + Str$(j)).Visible = False
Reports(r_name)("uom" + Str$(j)).Caption = "M"
Reports(r_name)("com" + Str$(j)).Visible = False
Reports(r_name)("com" + Str$(j)).Caption = "M"
Next
'*********** SET BOTH RECORDSETS TO FIRST RECORD ***********
res.MoveFirst
st.MoveFirst
current_group = "General"
'********** CYCLE THROUGH BOXES UP TO 44 ******************
For I = 1 To 44
print_pos = I
check_eof:
If st.EOF Then 'check for last result record
If res.EOF Then
Exit Sub
End If
End If
If res.EOF Then GoTo print_standard
If res![Lab Ref No] = LabREF Then
GoTo process_labref
Else
res.MoveNext
GoTo check_eof
End If
process_labref:
If st.EOF Then GoTo print_results
resgrp = res!t_grp
tgrp = st!t_grp
tpos = st!f_pos
respos = res!f_pos
If resgrp > tgrp Then GoTo print_standard
If resgrp < tgrp Then GoTo print_results
If resgrp = tgrp Then GoTo compare_positions
MsgBox "error in group sorting"
compare_positions:
If tpos > respos Then GoTo print_results 'compare print positions
If tpos < respos Then GoTo print_standard ' and print the lowest
If tpos = respos Then GoTo print_both
MsgBox "error in position sorting"
print_results:
If res!t_grp > current_group Then
print_pos = print_pos + 1
I = I + 1
End If
equivalence = res!Equiv
testvalue = res!Value
testuom = res!UOM
If IsNull(res!p_comm) Then
comments = " "
Else
comments = res!p_comm
End If
current_group = res!t_grp 'set current group to
testname = res!T_name
Call PrintResultValues(LabREF, repname, testname, equivalence, testvalue, testuom, comments, print_pos)
res.MoveNext ' one being printed
GoTo last_line
print_standard:
If st!t_grp > current_group Then
I = I + 1
print_pos = print_pos + 1
End If
testname = st!T_name
current_group = st!t_grp 'set current group to one being printed
Call Printst(repname, testname, print_pos) 'PRINT st TEXT
'MsgBox "current group is now " & current_group
st.MoveNext 'MOVENEXT st
GoTo last_line
print_both:
If res!t_grp > current_group Then
I = I + 1
print_pos = print_pos + 1
End If
current_group = res!t_grp 'set current group to one being printed
testname = res!T_name
equivalence = res!Equiv
testvalue = res!Value
testuom = res!UOM
If IsNull(res!p_comm) Then
comments = " "
Else
comments = res!p_comm
End If
Call PrintResultValues(LabREF, repname, testname, equivalence, testvalue, testuom, comments, print_pos)
res.MoveNext
st.MoveNext
GoTo last_line
last_line:
'If resgrp > current_group Then 'Check for new group and
' If tgrp > current_group Then I = I + 1 'leave space if true
'End If
check_nomatch:
If res!EOF = True Then
If st!EOF = True Then
Exit Sub
End If
End If
skip_record:
Next
Exit Sub
End Sub