dcsimg
Results 1 to 4 of 4

Thread: [RESOLVED] how to write the code for import excel data to access database??

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2009
    Posts
    108

    Resolved [RESOLVED] how to write the code for import excel data to access database??

    hi,
    Anyone can help how to write the vb6 code for import excel data to my database file (mdb), because my excel have more than 10,000.00 code to manually key in to my database file. Another problem is my client computer doesn’t want to use Microsoft access to open the database file. Any other way to write the vb6 code for import to my database?

    Example:
    a.) I use the data control to connect to my database (mdb).

    b.) When I click the command button1 will browse the excel file and commandbutton2 will import excel data file to my database (mdb).

    Any one help is much appreciated, Thank you.

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    24,513

    Re: how to write the code for import excel data to access database??

    you can use
    insert into table query
    where table is your access database table and query is an sql query on your excel worksheet

    i would avoid using bound controls, but use reference to activex data objects (ADO)

    see http://support.microsoft.com/kb/257819
    for information on using ADO with excel
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2009
    Posts
    108

    Re: how to write the code for import excel data to access database??

    thank you for your reply and info, can you provide some simple example code for me to reference?
    (eg: my excel file is book1.xls and mydata.mdb is my database)

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    24,513

    Re: how to write the code for import excel data to access database??

    there would be many examples in this and the database forum for connecting to an access database, and the link i posted above gives comprehensive instruction to connect to an excel worksheet, so it should not be hard for you to write some code to get started, if you have problems, post back with the code you are trying and specify what problem and where it is happening, so people can help you
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width