M
michellesihdu
Hi all
My name is Michelle.
I'm having some problems importing data to my Access DB. I¡¦ve imported
it first from an excelfile, which I made a txt file of, which is just
fine, but when I want to take that data and put it in my DB all I get
is syntax error. I have to do some extra stuff with the data from the
excelfile since it doesn¡¦t contain all columns.
My code looks like this:
strSQLImport = "SELECT tblImportToSplit.ImportData " _
& "FROM tblImportToSplit"
Line Input #intFile, strFile
Do While EOF(intFile) = False
varArray = Split(strFile, ";")
date = varArray(0)
bildNr = varArray(1)
description = varArray(2)
magasineName = varArray(3)
-----„³ this works just fine, I get all data that¡¦s in the excelfile.
'--- Check if magasineName exists
check = DLookup("magasineId", "Photos", "[magasineName] ='" &
magasineName & "' ")
If IsNull([check]) Then
'MsgBox "New magasine"
'----- boxId
boxId = DMax("boxId", "Photos", "")
'----- rowId
highestRowid = DMax("rowId", "Photos", "")
thisRowId = highestRowid + 1
'--- MagasineId
magasineId = "A"
'--- pictureId
pictureId = 1
boxId = boxId
magasineName = magasineName
magasineId = magasineId
x = Null
-----„³ I¡¦ve tried all of these INSERT INTO, but I just get ¡§SYNTAX
ERROR insert into
'SQLstr1 = "INSERT INTO Photos [(boxId[, magasineName
[,magasineId]])] VALUES (boxId[, magasineName[,magasineId]])
'SQLstr1 = "INSERT INTO Photos [(magasineName])] values '" &
boxId & "', '" & magasineName & "', '" & magasineId & "' ;"
'SQLstr1 = "INSERT INTO tblExcelData SELECT * FROM " &
tdf.Name
'SQLstr1 = "INSERT INTO Photos [(boxId[, magasineName[,
magasineId]]])] values " & boxId & "', '" & magsineName & "', '" &
magsineId & "' ;"
SQLstr1 = "SELECT * INTO [Photos] FROM " & tblImportToSplit &
";"
'SQLstr1 = "INSERT INTO [Photos] (x,
bildNr,date,description,magsineName,x, x, x,
thisRowId,,magsineId,boxId,pictureId); "
''SQLstr1 = "INSERT INTO [Photos] select " & (varArray(9));
CurrentDb.Execute SQLstr1
Any help would make me happy.
Thanks in advance
/Michelle
My name is Michelle.
I'm having some problems importing data to my Access DB. I¡¦ve imported
it first from an excelfile, which I made a txt file of, which is just
fine, but when I want to take that data and put it in my DB all I get
is syntax error. I have to do some extra stuff with the data from the
excelfile since it doesn¡¦t contain all columns.
My code looks like this:
strSQLImport = "SELECT tblImportToSplit.ImportData " _
& "FROM tblImportToSplit"
Line Input #intFile, strFile
Do While EOF(intFile) = False
varArray = Split(strFile, ";")
date = varArray(0)
bildNr = varArray(1)
description = varArray(2)
magasineName = varArray(3)
-----„³ this works just fine, I get all data that¡¦s in the excelfile.
'--- Check if magasineName exists
check = DLookup("magasineId", "Photos", "[magasineName] ='" &
magasineName & "' ")
If IsNull([check]) Then
'MsgBox "New magasine"
'----- boxId
boxId = DMax("boxId", "Photos", "")
'----- rowId
highestRowid = DMax("rowId", "Photos", "")
thisRowId = highestRowid + 1
'--- MagasineId
magasineId = "A"
'--- pictureId
pictureId = 1
boxId = boxId
magasineName = magasineName
magasineId = magasineId
x = Null
-----„³ I¡¦ve tried all of these INSERT INTO, but I just get ¡§SYNTAX
ERROR insert into
'SQLstr1 = "INSERT INTO Photos [(boxId[, magasineName
[,magasineId]])] VALUES (boxId[, magasineName[,magasineId]])
'SQLstr1 = "INSERT INTO Photos [(magasineName])] values '" &
boxId & "', '" & magasineName & "', '" & magasineId & "' ;"
'SQLstr1 = "INSERT INTO tblExcelData SELECT * FROM " &
tdf.Name
'SQLstr1 = "INSERT INTO Photos [(boxId[, magasineName[,
magasineId]]])] values " & boxId & "', '" & magsineName & "', '" &
magsineId & "' ;"
SQLstr1 = "SELECT * INTO [Photos] FROM " & tblImportToSplit &
";"
'SQLstr1 = "INSERT INTO [Photos] (x,
bildNr,date,description,magsineName,x, x, x,
thisRowId,,magsineId,boxId,pictureId); "
''SQLstr1 = "INSERT INTO [Photos] select " & (varArray(9));
CurrentDb.Execute SQLstr1
Any help would make me happy.
Thanks in advance
/Michelle