Does anybody can help me with my problem? 
Author Message
 Does anybody can help me with my problem?

Problem:
I have an excel worksheet. I created a procedure with VBA that reads out all
my variables from the worksheet into an .csv file. Next I want to open an
acces database using VBA in the same procedure and write the .csv file into
the access database wich already exists.
I am a trainee at the international business school in Arnhem, the
Netherlands. I am learning for system engineer but I cannot find a sollution
for my problem. Maybe one of you can help me with my problem

Thanks in advance.

Gilles Pol
Arnhem, The Netherlands



Fri, 04 May 2001 03:00:00 GMT  
 Does anybody can help me with my problem?
Hi Gilles Pol,

Set a reference to Access Type Library under Tools/References.  Then use
Automation to start a new instance of Access, issue a Docmd.TransferText on
the CSV file.  You might have to define and use a custom Import
Specification if some data comes in weird.

HTH
--
Dev Ashish (Just my $.001)
---------------
The Access Web ( http://home.att.net/~dashish )
---------------

Quote:

>Problem:
>I have an excel worksheet. I created a procedure with VBA that reads out
all
>my variables from the worksheet into an .csv file. Next I want to open an
>acces database using VBA in the same procedure and write the .csv file into
>the access database wich already exists.
>I am a trainee at the international business school in Arnhem, the
>Netherlands. I am learning for system engineer but I cannot find a
sollution
>for my problem. Maybe one of you can help me with my problem

>Thanks in advance.

>Gilles Pol
>Arnhem, The Netherlands



Fri, 04 May 2001 03:00:00 GMT  
 Does anybody can help me with my problem?
Here is a VBA macro that does what you want using DAO.  You must have a
reference to 'MS DAO 3.0 Object Library' in theTools-References menu.

Brian Walton

Sub db1()

Dim oMyDB As Database
Dim oMyDBrs As Recordset
Dim iMyFreeFile As Integer
Dim sField0 As String
Dim sField1 As String

' open the database you want to write to
Set oMyDB = Workspaces(0).OpenDatabase("c:\mydocu~1\xltest.mdb")
' set the recordset to the table you want to write to
Set oMyDBrs = oMyDB.OpenRecordset("table1", dbOpenDynaset)

' get a freefile number
iMyFreeFile = FreeFile

' open the csv file
Open "c:\mydocu~1\xltest.csv" For Input As #iMyFreeFile

' loop through the csv file & write to the database
Do While Not EOF(iMyFreeFile)
    ' get the next two fields in the csv file
    Input #iMyFreeFile, sField0, sField1
    ' create a new record
    oMyDBrs.AddNew
    ' must update the record after creating new
    oMyDBrs.Update
    ' make sure you are on new record you just created
    oMyDBrs.MoveLast
    ' go into edit mode
    oMyDBrs.Edit
    ' update the record.
    oMyDBrs.Fields(0).Value = sField0
    oMyDBrs.Fields(1).Value = sField1
    oMyDBrs.Update
Loop

' now close the file
Close #iMyFreeFile

End Sub



Fri, 04 May 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Anybody done a VB5 Web App?

2. Doe's anybody knows how to...

3. Anybody done this??

4. Anybody done a 2 checkboxes per row dropdown list

5. Help anybody know what my problem is?

6. Help anybody know what my problem is?

7. Help anybody know what my problem is?

8. Can anybody help with this problem ?

9. Help anybody know what my problem is?

10. Help, anybody. Printer problem

11. Help, Performance problems doing mass updates

12. Anybody have some good canned RTF routines (or class)?

 

 
Powered by phpBB® Forum Software