Below is the code I am stuck on (the sql is clearly not the right way to go, there ought to be a "FROM" bit). The "rem" is the bit where I need help --I remmed it because it doesn't work.
I am trying to append data into an existing table, based on data created in vba (after picking up document names in a directory).
Here is the code I have:
Dim strDocname, strLocation
strLocation = "xxnotrelevant"
strDocname = Dir(strLocation)
Do While strDocname <> ""
If strDocname <> "." And strDocname <> ".." Then
'Parse the document name to get the data needed, where document name saved is in the format "Neumonic=CoordID-RefID+Description.doc" ignoring "neumonic" which is just for visual help
Dim CoordID, RefId, strDocdescription, PosCoord, PosRef, PosDescription
PosCoord = InStr(1, strDocname, "="
+ 1
PosRef = InStr(1, strDocname, "-"
+ 1
PosDescription = InStr(1, strDocname, "+"
+ 1
CoordID = Mid(strDocname, PosCoord, PosRef - 1 - PosCoord)
RefId = Mid(strDocname, PosRef, PosDescription - 1 - PosRef)
strDocdescription = Mid(strDocname, PosDescription, Len(strDocname) - 3 - PosDescription)
'now append to table
Dim db As Database, strSQL, strTargettable
strTargettable = "Coordinate Correspondance"
Set db = CurrentDb
Rem strSQL = "INSERT INTO [Coordinate Correspondance] ( [Reference ID], [Coordinate ID], [Description] ) SELECT RefID, CoordID, strDocdescription;"
db.Execute strSQL
End If
strDocname = Dir
Loop
I clearly don't know how to bring the data I have in hand in VBA into a table. Would sure appreciate some help.
Thanks
Riny
I am trying to append data into an existing table, based on data created in vba (after picking up document names in a directory).
Here is the code I have:
Dim strDocname, strLocation
strLocation = "xxnotrelevant"
strDocname = Dir(strLocation)
Do While strDocname <> ""
If strDocname <> "." And strDocname <> ".." Then
'Parse the document name to get the data needed, where document name saved is in the format "Neumonic=CoordID-RefID+Description.doc" ignoring "neumonic" which is just for visual help
Dim CoordID, RefId, strDocdescription, PosCoord, PosRef, PosDescription
PosCoord = InStr(1, strDocname, "="
PosRef = InStr(1, strDocname, "-"
PosDescription = InStr(1, strDocname, "+"
CoordID = Mid(strDocname, PosCoord, PosRef - 1 - PosCoord)
RefId = Mid(strDocname, PosRef, PosDescription - 1 - PosRef)
strDocdescription = Mid(strDocname, PosDescription, Len(strDocname) - 3 - PosDescription)
'now append to table
Dim db As Database, strSQL, strTargettable
strTargettable = "Coordinate Correspondance"
Set db = CurrentDb
Rem strSQL = "INSERT INTO [Coordinate Correspondance] ( [Reference ID], [Coordinate ID], [Description] ) SELECT RefID, CoordID, strDocdescription;"
db.Execute strSQL
End If
strDocname = Dir
Loop
I clearly don't know how to bring the data I have in hand in VBA into a table. Would sure appreciate some help.
Thanks
Riny