View Single Post
  #1 (permalink)  
Old September 20th, 2011, 12:54 PM
cdaye99 cdaye99 is offline
Registered User
 
Join Date: Aug 2008
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default "Object required" error

I'm getting an "Object required" error when I return to a Sub to write another record (In red below) after the file has been open. Below is the Sub. I have several output files, but don't always have output data for each file depending on the input. I do the check to prevent empty output files.

Any idea on why the objOutputFile_CIF_OneRow doesn't exist when I come back into the SUB? I have verified I'm not closing the object.



Public Sub subWriteOutput ( sDocType, sFileNameOut, sAcctType, sAcct, sDocTypeId, sDocDate, sScanOper, sDescPrompt, sConvToPDF)
'*********** Calculate length of sFileName and remove extension and change to .TIF for PDF conversion - above add in sOutRec below
iInactive = 0
iReceived = 1
sScanDate = Date
msgbox "output"

If sDocType = "CIF" Then
sOutRec = strImgOutput_file_path & sFileNameOut & vbTab & sDocTypeId & vbTab & sCif & vbTab & sDocDate & _
vbTab & iReceived & vbTab & iInactive & vbTab & sScanDate & vbTab & sScanOper & vbTab & sDescPrompt & _
vbTab & sCif & "-" & sDocTypeId & vbCrLf
'msgbox sOutRec
If sConvToPDF = "Y" Then
If sOneRowOnly = "Y" Then
If sOpen_CIF_OneRow = "N" Then
strOutput_Cif_OneRow = strTxtOutput_file_path & strLoanDepSwitch & "-Cif-OneRow.txt"
If objFSO.FileExists(strOutput_Cif_OneRow) Then
msg_num = Err.Number
msg_desc = "Output file already exists = " & strOutput_Cif_OneRow
Call LogEvent (strEventLog,strSourceName,msg_num,msg_desc,1,"loc al")
subExitProgram
Else
Set objOutputFile_CIF_OneRow = objFSO.OpenTextFile(strOutput_Cif_OneRow,ForWritin g,True)
End If
sOpen_CIF_OneRow = "Y"
End If
objOutputFile_CIF_OneRow.Write sOutrec

Else
If sOpen_CIF_NewRow = "N" Then
strOutput_Cif_NewRow = strTxtOutput_file_path & strLoanDepSwitch & "-Cif-NewRow.txt"
If objFSO.FileExists(strOutput_Cif_NewRow) Then
msg_num = Err.Number
msg_desc = "Output file already exists = " & strOutput_Cif_NewRow
Call LogEvent (strEventLog,strSourceName,msg_num,msg_desc,1,"loc al")
subExitProgram
Else
Set objOutputFile_CIF_NewRow = objFSO.OpenTextFile(strOutput_Cif_NewRow,ForWritin g,True)
End If
sOpen_CIF_NewRow = "Y"
End If

objOutputFile_CIF_NewRow.Write sOutrec
End If
Else
If sOneRowOnly = "Y" Then
If sOpen_CIF_OneRowPDF = "N" Then
strOutput_Cif_OneRowPDF = strTxtOutput_file_path & strLoanDepSwitch & "-Cif-OneRowPDF.txt"
If objFSO.FileExists(strOutput_Cif_OneRowPDF) Then
msg_num = Err.Number
msg_desc = "Output file already exists = " & strOutput_Cif_OneRowPDF
Call LogEvent (strEventLog,strSourceName,msg_num,msg_desc,1,"loc al")
subExitProgram
Else
Set objOutputFile_CIF_OneRowPDF = objFSO.OpenTextFile(strOutput_Cif_OneRowPDF,ForWri ting,True)
End If
sOpen_CIF_OneRowPDF = "Y"
End If
objOutputFile_CIF_OneRowPDF.Write sOutrec
Else
If sOpen_CIF_NewRowPDF = "N" Then
strOutput_Cif_NewRowPDF = strTxtOutput_file_path & strLoanDepSwitch & "-Cif-NewRowPDF.txt"
If objFSO.FileExists(strOutput_Cif_NewRowPDF) Then
msg_num = Err.Number
msg_desc = "Output file already exists = " & strOutput_Cif_NewRowPDF
Call LogEvent (strEventLog,strSourceName,msg_num,msg_desc,1,"loc al")
subExitProgram
Else
Set objOutputFile_CIF_NewRowPDF = objFSO.OpenTextFile(strOutput_Cif_NewRowPDF,ForWri ting,True)
End If
sOpen_CIF_NewRowPDF = "Y"
End If

objOutputFile_CIF_NewRowPDF.Write sOutrec
End If

End If
End If
If sDocType = "ACCT" Then
sOutRec = strImgOutput_file_path & sFileNameOut & vbTab & sDocTypeId & vbTab & sAcctType & sAcct & vbTab & sDocDate & _
vbTab & iReceived & vbTab & iInactive & vbTab & sScanDate & vbTab & sScanOper & vbTab & sDescPrompt & _
vbTab & sAcctType & sAcct & "-" & sDocTypeId & vbCrLf
If sConvToPDF = "Y" Then
If sOneRowOnly = "Y" Then
If sOpen_Acct_OneRow = "N" Then
strOutput_Acct_OneRow = strTxtOutput_file_path & strLoanDepSwitch & "-OneRow.txt"
If objFSO.FileExists(strOutput_Deposit_OneRow) Then
msg_num = Err.Number
msg_desc = "Output file already exists = " & strOutput_Acct_OneRow
Call LogEvent (strEventLog,strSourceName,msg_num,msg_desc,1,"loc al")
subExitProgram
Else
Set objOutputFile_Acct_OneRow = objFSO.OpenTextFile(strOutput_Acct_OneRow,ForWriti ng,True)
End If
sOpen_Acct_OneRow = "Y"
End If
objOutputFile_Acct_OneRow.Write sOutrec
Else
If sOpen_Acct_NewRow = "N" Then
strOutput_Acct_NewRow = strTxtOutput_file_path & strLoanDepSwitch & "-NewRow.txt"
If objFSO.FileExists(strOutput_Acct_NewRow) Then
msg_num = Err.Number
msg_desc = "Output file already exists = " & strOutput_Acct_NewRow
Call LogEvent (strEventLog,strSourceName,msg_num,msg_desc,1,"loc al")
subExitProgram
Else
Set objOutputFile_Acct_NewRow = objFSO.OpenTextFile(strOutput_Acct_NewRow,ForWriti ng,True)
End If
sOpen_Acct_NewRow = "Y"
End If
objOutputFile_Acct_NewRow.Write sOutrec
End If
Else
If sOneRowOnly = "Y" Then
If sOpen_Acct_OneRowPDF = "N" Then
strOutput_Acct_OneRowPDF = strTxtOutput_file_path & strLoanDepSwitch & "-OneRowPDF.txt"
If objFSO.FileExists(strOutput_Deposit_OneRowPDF) Then
msg_num = Err.Number
msg_desc = "Output file already exists = " & strOutput_Acct_OneRowPDF
Call LogEvent (strEventLog,strSourceName,msg_num,msg_desc,1,"loc al")
subExitProgram
Else
Set objOutputFile_Acct_OneRowPDF = objFSO.OpenTextFile(strOutput_Acct_OneRowPDF,ForWr iting,True)
End If
sOpen_Acct_OneRowPDF = "Y"
End If
objOutputFile_Acct_OneRowPDF.Write sOutrec
Else
If sOpen_Acct_NewRowPDF = "N" Then
strOutput_Acct_NewRowPDF = strTxtOutput_file_path & strLoanDepSwitch & "-NewRowPDF.txt"
If objFSO.FileExists(strOutput_Acct_NewRowPDF) Then
msg_num = Err.Number
msg_desc = "Output file already exists = " & strOutput_Acct_NewRowPDF
Call LogEvent (strEventLog,strSourceName,msg_num,msg_desc,1,"loc al")
subExitProgram
Else
Set objOutputFile_Acct_NewRowPDF = objFSO.OpenTextFile(strOutput_Acct_NewRowPDF,ForWr iting,True)
End If
sOpen_Acct_NewRowPDF = "Y"
End If
objOutputFile_Acct_NewRowPDF.Write sOutrec
End If
End If
End If

End Sub
Reply With Quote