Problem with DAO (Import from Excel to Access)! :(

A

And1

Hi,
I am novice and I have problem. I need import some data with Excel file
to Access.
Problem introduces as follows:
In Excel(first sheet) i have data:
"TYTUL" - column "A"
"NAZWISKO" - column "B"
"IMIE" - column "C"
"PRZEDMIOT" - column "D".
Excel file name is AND.xls

In Access i have table - AS_PRZEDMIOT.
Table "AS_PRZEDMIOT" contains fields:
ID_PRZEDMIOT (Auto),
P_AKTYWNY (Number),
P_ID_GRUPA (Number),
P_ID_KATEDRA (Number),
P_ID_KIERUNEK (Number),
P_NAZWA (String),
P_NAZWA_0 (String),
P_NAZWA01 (String),
P_SKROT (String),
P_UWAGI (String)
UPDATE_DATE (Number),
UPDATE_USER (String),
P_SKROT_0 (String),
P_SKROT_01 (String).

I need import data from Excel (PRZEDMIOTY - column "D") to Access (field
P_NAZWA). Additionally to every record in field P_AKTYWNY insert number "1".

How to do?
I try in support about example modules VBA (in Accesss):
but I do not know how to modify (use) this code?
How to make this the best?

Sub Test(Tabela_rs As String)

Dim rs As DAO.Recordset
Dim rd As DAO.Recordset


Set rs = CurrentDb.OpenRecordset(Tabela_rs, dbOpenSnapshot)
Set rd = CurrentDb.OpenRecordset("AS_Przedmiot")



rs.MoveFirst

While Not rs.EOF

rd.AddNew

'rd![ID_PRZEDMIOT] = rs![ID_PRZEDMIOT]
rd![P_NAZWA] = rs![P_NAZWA]

' .....

rd.Update

rs.MoveNext

Wend

End Sub

Sub StartTest()
Test ("AS_Przedmiot")
MsgBox "sukces"
End Sub

Kind Regards,
Andrzej.
 
S

Stefan Hoffmann

hi And1,
Hi,
I am novice and I have problem. I need import some data with Excel file
to Access.
Problem introduces as follows:
In Excel(first sheet) i have data:
"TYTUL" - column "A"
"NAZWISKO" - column "B"
"IMIE" - column "C"
"PRZEDMIOT" - column "D".
Excel file name is AND.xls

In Access i have table - AS_PRZEDMIOT.
I need import data from Excel (PRZEDMIOTY - column "D") to Access (field
P_NAZWA). Additionally to every record in field P_AKTYWNY insert number
"1".
You can use

INSERT INTO [AS_PRZEDMIOT] ([P_NAZWA])
SELECT [PRZEDMIOTY]
FROM [Excel 8.0;Database=YourExcel;Hdr=Yes].[NameOfSheet$]

as SQL statement in an ordenary query.


mfG
--> stefan <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top