+ Reply to Thread
Results 1 to 2 of 2

How to use VBA to insert record into database table when there is missing value?

  1. #1
    Forum Contributor
    Join Date
    09-10-2016
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    680

    How to use VBA to insert record into database table when there is missing value?

    1. The code works fine if there is no missing value. I have tested on one record and multiple records, the code runs fine.
    2. Please note that I write FieldD and FieldF differently, because these two fields are string, the remaining five fields are integer.
    3. I tested the code on a file with one single record, and if only FieldF is missing, the code runs fine and is able to insert the other 6 fields into database table.
    4. I tested the code on a file with one single record, and if only FieldE is missing, the code does not run, see the attached error message.

    Column A will never be missing, so it is fine for the code to check LastRow.

    I need to add some space in SQL code, in order to post the code.

    Please Login or Register  to view this content.

    Another question: how to test if a record is already in the database table? The database system will generate error message if the identical record is already in the database table, how should I use VBA to check it then I can skip adding that record.

    Thanks.
    Attached Images Attached Images
    Last edited by VAer; 03-10-2017 at 01:59 PM.

  2. #2
    Forum Contributor
    Join Date
    09-10-2016
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    680

    Re: How to use VBA to insert record into database table when there is missing value?

    Delete.......

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Adding new record to existing database table with a form
    By Mongoloid in forum Access Tables & Databases
    Replies: 2
    Last Post: 11-10-2016, 03:58 PM
  2. Replies: 2
    Last Post: 09-08-2014, 05:31 PM
  3. Missing Insert table row below
    By noctornus in forum Excel General
    Replies: 1
    Last Post: 02-27-2013, 01:58 PM
  4. VBA Excel Code to Insert New Record into MS Access Database
    By Vladamir in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-28-2012, 09:15 AM
  5. Add a record to a database table from excel
    By mcinnes01 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-05-2011, 08:11 AM
  6. problem using ado to insert record into excel table
    By marktheman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-16-2007, 04:18 PM
  7. Replies: 3
    Last Post: 07-30-2005, 11:05 PM

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