I have written an import procedure and an export procedure. The Import procedure works well but the export procedure is what is giving me the error. I have tried everything but the error is telling me that the string is not being cleared. What can I do ?
Tom
Tom
Code:
Function ImportCS(strClientName As String)
Dim strPath As String
Dim strTbl1Name As String
Dim strTbl2Name As String
Dim strFileExt As String
Dim strCurRptMon As String
Dim strCurMon As String
Dim intPd As Integer
Dim strCurMonL As String
Dim strCurMonS As String
Dim intCurFiscalMon As Integer
Dim intCurFiscalYr As Integer
Dim intFiscalMon As Integer
Dim intCurCalYr As Integer
Dim intCurRptMon As Integer
Dim intCurRptYr As Integer
Dim dtCurDate As Date
Dim strSpecName As String
Dim strTbl1Namewoext As String
Dim strDelete As String
Dim intX As Integer
Dim intTblNme As Integer
Dim strSQL As String
Dim rst As Recordset
strPath = "S:\"
strFileExt = ".txt"
DoCmd.SetWarnings False
strSpecName = "IMP_CS_SPEC"
' PROCEDURE TO GET DATA
strSQL = " SELECT rptpd,rptpddiff,csfile" & _
" FROM dbo_rpt_FYInfo" & _
" WHERE rptpddiff = 1 AND uci ='SSH';"
Debug.Print strSQL
Set rst = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
If Not rst.EOF Then
With rst
.MoveLast
.MoveFirst
End With
strCSFile = (rst![csfile])
strRptPd = (rst![rptpd])
End If
rst.Close
Set rst = Nothing
strTbl1Namewoext = "impCS"
DoCmd.TransferText TransferType:=acImportDelim, _
SpecificationName:=strSpecName, _
TableName:=strTbl1Namewoext, _
FileName:=strPath & strCSFile, _
HasFieldNames:=True
MsgBox strTbl1Namewoext & " has been imported"
DoCmd.SetWarnings True
End Function
'Export Procedure
Public Function Export(strUCI As String)
Dim strSpecName As String
Dim strPath As String
Dim strCSFile As String
Dim strExportFile As String
Dim strMonNm As String
Dim strCY As String
Dim strTable As String
Dim strSQL As String
Dim rst As Recordset
strPath = ""
strFileExt = ""
strTable = ""
strSpecName = ""
strPath = "W:\_RptSets\OTHER\" & strUCI & "\"
strFileExt = ".txt"
strTable = "SSH_ChargeExtract_"
DoCmd.SetWarnings False
strSpecName = "EXP_ChgExtract"
' PROCEDURE TO GET DATA
strSQL = " SELECT uci,mon_nm,cy,rptpddiff" & _
" FROM dbo_rpt_FYInfo" & _
" WHERE rptpddiff = 1 AND uci ='SSH';"
Debug.Print strSQL
Set rst = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
If Not rst.EOF Then
With rst
.MoveLast
.MoveFirst
End With
strMonNm = (rst![mon_nm])
strCY = (rst![cy])
'strReturnString = (rst![cal_num]) & (rst![yr])
End If
rst.Close
Set rst = Nothing
strExportFile = "SSH_ChargeExtract_" & strMonNm & strCY & strFileExt
DoCmd.TransferText TransferType:=acExportDelim, _
SpecificationName:=strSpecName, _
TableName:=strTable, _
FileName:=strPath & strExportFile, _
HasFieldNames:=True
MsgBox strExportFile & " has been exported"
DoCmd.SetWarnings True
End Function