Group:  Microsoft Access ยป microsoft.public.access.modulesdaovba.ado
Thread: Problem with DAO (Import from Excel to Access)! :(

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Problem with DAO (Import from Excel to Access)! :(
And1 <andrzpie[ at ]poczta.onet.pl> 02.08.2006 17:15:42
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.
Re: Problem with DAO (Import from Excel to Access)! :(
Stefan Hoffmann <stefan.hoffmann[ at ]explido.de> 03.08.2006 08:13:42
hi And1,

And1 wrote:
[Quoted Text]
> 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 <--


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net