D
Davo
Having problems with type-mismatch when trying to import to a table
(DD_Report). The date field is [DateofReport] with a shortdate format, input
mask of 99/99/00;;_. In the beginning the data wouldn't even import. Code
is shown below -- I've removed some areas that don't have anything to do with
this date problem. Thanks.
Dim req_error As Integer, filedata As String, key As String, flag As Integer
Dim filename As String, temp_date As String, RptDate As Date
ReDim mydata(2 To 8)
Dim MyTable As DAO.Recordset
Set MyTable = CurrentDb.OpenRecordset("DD_Report")
Open filename For Input As #1
flag = 0
Do While Not EOF(1)
Line Input #1, filedata
If Len(filedata) > 0 Then
key = Left$(filedata, 4)
If key = "DATE" Then
temp_date = Trim$(Mid$(filedata, 12, 8))
RptDate = CDate(Left(temp_date, 8))
End If
flag = 1
End If
'Start Import routine to Access Table
If flag = 1 Then
MyTable.AddNew
MyTable("DateofReport") = RptDate
MyTable.Update
flag = 0
End If
End If
Loop
(DD_Report). The date field is [DateofReport] with a shortdate format, input
mask of 99/99/00;;_. In the beginning the data wouldn't even import. Code
is shown below -- I've removed some areas that don't have anything to do with
this date problem. Thanks.
Dim req_error As Integer, filedata As String, key As String, flag As Integer
Dim filename As String, temp_date As String, RptDate As Date
ReDim mydata(2 To 8)
Dim MyTable As DAO.Recordset
Set MyTable = CurrentDb.OpenRecordset("DD_Report")
Open filename For Input As #1
flag = 0
Do While Not EOF(1)
Line Input #1, filedata
If Len(filedata) > 0 Then
key = Left$(filedata, 4)
If key = "DATE" Then
temp_date = Trim$(Mid$(filedata, 12, 8))
RptDate = CDate(Left(temp_date, 8))
End If
flag = 1
End If
'Start Import routine to Access Table
If flag = 1 Then
MyTable.AddNew
MyTable("DateofReport") = RptDate
MyTable.Update
flag = 0
End If
End If
Loop