Hi
I have an import routine that need to detect the type of data being imported based on the model type. The data are on spread sheets that are the same format but depending what the value is in the model field will determine what flags are to be set. my code does not seem to make any difference I have tried "If Then Else" and "If Then ElseIf" but it seem to treat both import file the same.
Any help appreciated.
I have an import routine that need to detect the type of data being imported based on the model type. The data are on spread sheets that are the same format but depending what the value is in the model field will determine what flags are to be set. my code does not seem to make any difference I have tried "If Then Else" and "If Then ElseIf" but it seem to treat both import file the same.
Any help appreciated.
Code:
Public Sub ImportConfig()
On Error GoTo ErrorHandler
Dim rsImport As DAO.Recordset
Dim rsExport As DAO.Recordset
Dim fld1 As DAO.Field
Dim fld2 As DAO.Field
Dim fldName As String
Set rsImport = CurrentDb.OpenRecordset("Product")
Set rsExport = CurrentDb.OpenRecordset("Import")
rsExport.AddNew
Do While Not rsImport.EOF
fldName = rsImport!Desc
Debug.Print fldName & " " & rsImport!Serial
rsExport.Fields(fldName) = rsImport!Serial
Debug.Print fldName & " " & rsExport!Serial
rsImport.MoveNext
rsExport![xxx] = Form.[xxx]
If rsExport.Fields(fldName) = "Model1" Then
rsExport.Fields("Model1") = -1
rsExport.Fields("Model2") = 0
rsExport.Fields("Delete") = 0
ElseIf rsExport.Fields(fldName) = "Model2" Then
rsExport.Fields("Model1") = 0
rsExport.Fields("Model2") = -1
rsExport.Fields("Delete") = -1
End If
Loop
rsExport.Update
ErrorHandler:
Resume Next
End Sub
Last edited: