peachmelba
Programmer
I have a file that I have created in Excel which has 21 columns. This is saved as a CSV file. I then import this file into Access using the following
Set rs = db.OpenRecordset(strTableName)
Do While Not EOF(1)
i = 0
rs.AddNew
Do Until i = intNoImportFields
With rs
Input #1, strFieldValue
Select Case strFieldValue
Case Is <> ""
.Fields(i).Value = strFieldValue
Case Else
'Check if field is mandatory
If varCheck(3, i) Then
![ErrorCode] = ![ErrorCode] - 1
End If
Select Case .Fields(i).Type
Case dbText
.Fields(i).Value = ""
Case dbDate
.Fields(i).Value = Null
Case dbNumeric
.Fields(i).Value = 0
Case dbBoolean
.Fields(i).Value = vbNo
Case Else
.Fields(i).Value = ""
End Select
End Select
End With
i = i + 1
Loop
rs.Update
Input #1, strFieldValue
Loop
This works great when the last row is populated and is really fast. But if i have a few cells with blank data at the end of each line when it is saved some commas are missing.
Does anyone know a away of using this function and checking which column or row I am in to make sure that I am not missing any commas?
Thanks
Peachmelba
Set rs = db.OpenRecordset(strTableName)
Do While Not EOF(1)
i = 0
rs.AddNew
Do Until i = intNoImportFields
With rs
Input #1, strFieldValue
Select Case strFieldValue
Case Is <> ""
.Fields(i).Value = strFieldValue
Case Else
'Check if field is mandatory
If varCheck(3, i) Then
![ErrorCode] = ![ErrorCode] - 1
End If
Select Case .Fields(i).Type
Case dbText
.Fields(i).Value = ""
Case dbDate
.Fields(i).Value = Null
Case dbNumeric
.Fields(i).Value = 0
Case dbBoolean
.Fields(i).Value = vbNo
Case Else
.Fields(i).Value = ""
End Select
End Select
End With
i = i + 1
Loop
rs.Update
Input #1, strFieldValue
Loop
This works great when the last row is populated and is really fast. But if i have a few cells with blank data at the end of each line when it is saved some commas are missing.
Does anyone know a away of using this function and checking which column or row I am in to make sure that I am not missing any commas?
Thanks
Peachmelba