chanman525
IS-IT--Management
My code....
Function import()
On Error GoTo import_Err
Dim receive As Database
Dim add_date As Field
Dim input_date As TableDef
Dim rec As Recordset
Dim path As String
Dim file_name As String
Dim import_filename As String
Dim month As String
Dim strFileExists As String
Dim year As String
Dim currentmonth As String
Dim Imported As Field
Dim strdate As String
Set receive = CurrentDb()
Set rec = receive.OpenRecordset("input_date")
path = "g:\prorep\tranhist\Receive\"
file_name = (rec!add_date & ".txt")
import_filename = path & file_name
strFileExists = dir(import_filename)
If strFileExists <> "" Then
year = Left$(file_name, 4)
month = Mid$(file_name, 5, 2)
currentmonth = year & month
strdate = Left(importdate!Imported, 4) & "-" & Mid(importdate!Imported, 5, 2) & "-" & Right(importdate!Imported, 2)
If Not IsDate(strdate) Then
Quit acQuitSaveAll
Else
import_filename = path & file_name
DoCmd.TransferText acImportDelim, "receive spec", currentmonth, import_filename, False, ""
End If
The issue I am having is with the line that starts strdate=...
The error comes up and says "variable not defined". Import date is a table and Imported is a text box displaying dates that have been imported.
The field shows dates in this structure...yyyymmdd
Can someone show me what I'm doing wrong?
Basically, I want to say, "If the date exists in the Imported field of the importdate table, then do not import.
Else,
import the date that I entered in the input_date field.
Thanks for the help guys.
Function import()
On Error GoTo import_Err
Dim receive As Database
Dim add_date As Field
Dim input_date As TableDef
Dim rec As Recordset
Dim path As String
Dim file_name As String
Dim import_filename As String
Dim month As String
Dim strFileExists As String
Dim year As String
Dim currentmonth As String
Dim Imported As Field
Dim strdate As String
Set receive = CurrentDb()
Set rec = receive.OpenRecordset("input_date")
path = "g:\prorep\tranhist\Receive\"
file_name = (rec!add_date & ".txt")
import_filename = path & file_name
strFileExists = dir(import_filename)
If strFileExists <> "" Then
year = Left$(file_name, 4)
month = Mid$(file_name, 5, 2)
currentmonth = year & month
strdate = Left(importdate!Imported, 4) & "-" & Mid(importdate!Imported, 5, 2) & "-" & Right(importdate!Imported, 2)
If Not IsDate(strdate) Then
Quit acQuitSaveAll
Else
import_filename = path & file_name
DoCmd.TransferText acImportDelim, "receive spec", currentmonth, import_filename, False, ""
End If
The issue I am having is with the line that starts strdate=...
The error comes up and says "variable not defined". Import date is a table and Imported is a text box displaying dates that have been imported.
The field shows dates in this structure...yyyymmdd
Can someone show me what I'm doing wrong?
Basically, I want to say, "If the date exists in the Imported field of the importdate table, then do not import.
Else,
import the date that I entered in the input_date field.
Thanks for the help guys.