mikebrewer
Registered User.
- Local time
- Today, 15:55
- Joined
- Sep 28, 2011
- Messages
- 93
Hey all,
kind of an odd question but here is what I'm trying to do...
I'm attempting to build an import module so that my users can take data from different walks of life and import it into my tables. I'm doing this by setting up a module and allowing the user to specify which column data will come from when importing data. So lets say I have a field that is CustomerID in my table and user one pulls data from 1 place and in his excel or csv file, customerid is in field 1. Another user does the same thing and its in field 2.
How can i make some form of a loop that when I'm attempting to update data, i pull the correct column? see the below code snippet i was starting with:
strSQL = "SELECT * FROM tblImportTable"
Set rst = db.OpenRecordset(strSQL, dbOpenDynaset, dbSeeChanges)
With rst
Do While .EOF = False
If IsNull(DLookup("DefaultValue", "dbo_tblImportTemplateDetails", "Template_ID=" & Forms!frmImport!TemplateName & " AND FieldName='CustomerID'")) Then
I NEED HELP RIGHT HERE TO LOOK FOR THE COLUMN NUMBER AND THEN ASSIGN THE COLUMN NUMBER TO CUSTOMERID. IF IT IS 1, I WOULD WANT rst!F1, if it is 2, then rst!F2 and so on and so forth. I feel there must be an easy way to do this other than a long check.
Else
CustomerID= DLookup("DefaultValue", "dbo_tblImportTemplateDetails", "Template_ID=" & Forms!frmImport!TemplateName & " AND FieldName='CustomerID'")
End If
Hopefully any of that makes sense.
thanks!!
kind of an odd question but here is what I'm trying to do...
I'm attempting to build an import module so that my users can take data from different walks of life and import it into my tables. I'm doing this by setting up a module and allowing the user to specify which column data will come from when importing data. So lets say I have a field that is CustomerID in my table and user one pulls data from 1 place and in his excel or csv file, customerid is in field 1. Another user does the same thing and its in field 2.
How can i make some form of a loop that when I'm attempting to update data, i pull the correct column? see the below code snippet i was starting with:
strSQL = "SELECT * FROM tblImportTable"
Set rst = db.OpenRecordset(strSQL, dbOpenDynaset, dbSeeChanges)
With rst
Do While .EOF = False
If IsNull(DLookup("DefaultValue", "dbo_tblImportTemplateDetails", "Template_ID=" & Forms!frmImport!TemplateName & " AND FieldName='CustomerID'")) Then
I NEED HELP RIGHT HERE TO LOOK FOR THE COLUMN NUMBER AND THEN ASSIGN THE COLUMN NUMBER TO CUSTOMERID. IF IT IS 1, I WOULD WANT rst!F1, if it is 2, then rst!F2 and so on and so forth. I feel there must be an easy way to do this other than a long check.
Else
CustomerID= DLookup("DefaultValue", "dbo_tblImportTemplateDetails", "Template_ID=" & Forms!frmImport!TemplateName & " AND FieldName='CustomerID'")
End If
Hopefully any of that makes sense.
thanks!!