Code:
Dim uname, uname2 As String
This doesn't do what you think. uname2 is declared as a string and uname is declared (implicitly) as a variant.
Could use
Code:
Dim uname As String, uname2 As String
I prefer to have each variable on a separate line.....
I modified your code to remove the "GOTO" lines and used "CurrentDb.Execute" instead of the recordset.
Code:
Option Compare Database 'should be at the top of every module
Option Explicit 'should be at the top of every module
Sub procrej()
On Error GoTo eh
Dim uname As String
Dim uname2 As String
'Identify actioning user
DoEvents
uname = Environ("USERNAME")
uname2 = UCase(uname)
'Ensures that the configuration data is present
If IsNull(DLookup("[REMA]", "APDT", "[ADID] = 1")) Or IsNull(DLookup("[REMB]", "APDT", "[ADID] = 1")) Then
'Config data missing error handler
MsgBox "Configuration data is missing! Please submit a service request so that production support can configure the application correctly.", vbOKOnly, "E054AA"
CurrentDb.Execute "INSERT INTO ACTN (ATUR, ATTD, ATTY, ATNT) VALUES ('" & uname2 & "', #" & Now & "#, 'DEBUG - UNEXPECTED ERROR', 'Missing configuration items');"
Else
'Display in progress form
DoCmd.OpenForm "RRPS"
'Call the processing subroutines
Call emailread
Call readrej
'Directs to the appropriate comms subroutine
If DLookup("[RJAP]", "APDT", "[ADID] = 1") = True Then
Call rejautproc
Else
Call rejmanproc
End If
'Close in progress form
DoCmd.Close acForm, "RRPS"
'Clear the temp cache
DoCmd.RunSQL "DELETE * FROM TRJP"
CurrentDb.Execute "DELETE * FROM TRJP", dbFailOnError
MsgBox "Rejected payments reports distributed and archival form printed at the local printer.", vbOKOnly, "I060RJ"
'Print hard copy archive report
DoCmd.OpenReport "LRPR", acViewNormal, , , acHidden '<<<<<<<<<**************This is where the problem occurs
End If
ender:
'Exit point for sub and re-open main menu
DoCmd.OpenForm "MMNU"
Exit Sub
eh: 'General and runtime error handler
CurrentDb.Execute "INSERT INTO ACTN (ATUR, ATTD, ATTY, ATNT) VALUES ('" & uname2 & "', #" & Now & "#, 'DEBUG - UNEXPECTED ERROR', " & Err.Number & "' - '" & Err.Description & "');"
MsgBox "A runtime error has occurred. Please submit a service request to have this bug investigated.", vbOKOnly, "E053AA"
Resume ender
End Sub
Feel free to ignore the changes...
Don't know if it will affect your print problem...... couldn't test it.....