Thanks for your reply. Yes, I have stepped through the code and have determined it is the line of code:
FunPortalPath (stRptPDFName, stPortalGrower)
That is throwing the syntax error. It also throws the error when I compile the code using Debug -> Compile.
At the top of the module that contains the function is Option Compare Database as well as it being at the top of the module that contains all the procedures for the form the code is written for.
The snip of code in the procedure that calls the function is as follow:
'setup recordset
Set db = CurrentDb()
Set rec = db.OpenRecordset("tblGrowerEmailRecSet")
intRecCount = rec.RecordCount
'initialize counter
intCount = 1
'define report name
ReportName
'move to frist record in record set
rec.MoveFirst
'loop through selected records
Do While Not rec.EOF
'if email exist than email if not then skip grower
If VBA.Len(rec!GrowerEmail) > 3 Then
'populate fields and variables
' Debug.Print intCount & " - " & rec!GrowerFarmName & " - " & rec!GrowerEmail
Me.comGrowerFrom = rec!GrowerFarmName
stPortalGrower = rec!GrowerFarmName
Me.comGrowerTo = Me.comGrowerFrom
Debug.Print "stRptPDFName = " & stRptPDFName
Debug.Print "stPortalGrower = " & stPortalGrower
'setup path - convert to function
If UCase(objNetwork.UserName) = "DARRENLIGHTFOOT" Then
FunPortalPath (stRptPDFName, stPortalGrower)
Else
PortalPath
End If
'save report as PDF
modEmailReports.SaveRptPDF stRptName, stPathPdfName
intCount = intCount + 1
End If
'move to the next record
rec.MoveNext
Loop
The procedure called (ReportName) determines the proper name for the report and writes it to the globally declared variable stRptPDFName. The variable stPortalGrower gets it value from the record set (rec).
When I comment out the line
FunPortalPath (stRptPDFName, stPortalGrower)
and set a break point at
If UCase(objNetwork.UserName) = "DARRENLIGHTFOOT" Then
The results of the two debug.print statements are:
stRptPDFName = 2019_01_Grower_Intake_Statement
stPortalGrower = GERALD_GOUCHER
So they shouldn't be null when the function is called.
Do you have any ideas? I really appreciate the help.
Thanks.