pbuethe
Returning User
- Local time
- Yesterday, 23:41
- Joined
- Apr 9, 2002
- Messages
- 210
Hello,
I have the following code to pre-fill some fields on a PDF form.
When I run this I get the error "object variable or With block variable not set" on the first jso.getField line.
I am running Access 2010.
Thanks in advance for your assistance.
I have the following code to pre-fill some fields on a PDF form.
Code:
Function basPreFill(strSample, strFacility, strCaseID As String)
Dim strWSFormName, strSql As String
Dim AcroApp As Acrobat.CAcroApp
Dim theWSForm As Acrobat.CAcroPDDoc
Dim rstCaseInfo As Recordset
Dim jso As Object
strWSFormName = conMainFolder & "Sample " & strSample & "\" & strFacility & "\" & strCaseID & "_WSForm.pdf"
Set AcroApp = CreateObject("AcroExch.App")
Set theWSForm = CreateObject("AcroExch.PDDoc")
If theWSForm.Open(strWSFormName) <> False Then 'PC_form already exist
MsgBox strWSFormName & " already exists. "
Exit Function
End If
theWSForm.Open ("V:\Master_DB\eChart\Worksheet Template\Review Worksheet_2018-07-01_R3Enable.pdf")
'* get case information
strSql = "SELECT CaseNbr, AdmitDate, DischDate, SequenceNbr, SampleNbr, Provider, County, " & _
[SampleNbr] & ' (' & [ReviewSite] & ' )' As SampleNbrReviewSite, Flag1, Flag2, Flag3, & _
PatientName, MedRecNbr, MedicaidID, DOB, Age, Sex, LOS, DRG, DRGSOI, DRGDesc & _
FROM tblWkshtHeader WHERE (((tblWkshtHeader.CaseNbr)= ' & Trim(strCaseID) & "'));"
'MsgBox strSql
Set rstCaseInfo = CurrentDb().OpenRecordset(strSql)
If rstCaseInfo.RecordCount <> 1 Then
'Debug.Print "Check case ID " & strCaseID
Exit Function
End If
Set jso = theWSForm.GetJSObject
jso.getField("CaseNbr#1").Value = Trim(rstCaseInfo("CaseNbr")) & ""
jso.getField("CaseNbr#1").ReadOnly = True
jso.getField("AdmitDate#1").Value = Trim(rstCaseInfo("AdmitDate")) & ""
jso.getField("AdmitDate#1").ReadOnly = True
jso.getField("DischDate#1").Value = Trim(rstCaseInfo("DischDate")) & ""
jso.getField("DischDate#1").ReadOnly = True
jso.getField("SequenceNbr#0").Value = Trim(rstCaseInfo("SequenceNbr")) & ""
jso.getField("SequenceNbr#0").ReadOnly = True
'there are more jso.getField statements for the rest of the fields, then:
jso.saveAs (strWSFormName)
AcroApp.Exit:
Set AcroApp = Nothing
rstCaseInfo.Close
theWSForm.Close
End Function
When I run this I get the error "object variable or With block variable not set" on the first jso.getField line.
I am running Access 2010.
Thanks in advance for your assistance.