+ Reply to Thread
Results 1 to 3 of 3

VBA Excel Code to Insert New Record into MS Access Database

  1. #1
    Registered User
    Join Date
    01-12-2012
    Location
    USA
    MS-Off Ver
    Excel 2007, 2003
    Posts
    84

    VBA Excel Code to Insert New Record into MS Access Database

    Forgive me for being such a newbie on these kind of things. I've got some really neat code running in Excel VBA which automates several engineering tasks. One of the last things I need to do is to collect some of the data in the Excel file and insert it as a new record in an MS Access database. Can VBA code in Excel do this?
    Wish I didn't know now what I didn't know then.

  2. #2
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: VBA Excel Code to Insert New Record into MS Access Database

    It surely can.
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  3. #3
    Registered User
    Join Date
    01-12-2012
    Location
    USA
    MS-Off Ver
    Excel 2007, 2003
    Posts
    84

    Re: VBA Excel Code to Insert New Record into MS Access Database

    Okay, you are certainly right. A quick search and I found this code to do the task:

    Please Login or Register  to view this content.
    And viola...it works perfectly. Now I have another snippet of code that I'm working with in VB.NET. It looks into the database and performs an SQL command to get the highest number in the DwgNo field. It adds one (+1) to that and returns the value to be used so that when the new record is added, the next sequential number for this field is also added.

    Please Login or Register  to view this content.
    I'm assuming (correctly, I hope) that this code will not work in VBA. Can anyone help me with how to modify this code so that I can do basically the same thing. That is to find the highest value in the DwgNo field, add 1 to it and then return this value so that when I commit the new record to the database I can include this new sequential number?
    Last edited by Vladamir; 06-28-2012 at 09:20 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1