CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2001
    Location
    South Africa
    Posts
    186

    Updating database

    Please help! I am a beginner with VB and need to update a DAO/Access 97 table with the old table data. The problem is that the new table has extra fields that's not in the old table.

    How can i check each field from the new table to see if the same field exist in the old table so that i can import the data if it exist or add a default value if the field does not exist.

    Any help please, i'm desperate!!!

    Wynand

  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Updating database

    A recordset has a fields collection, contining field objects. This way, you can do the check.

    Dim fldNew as Field
    Dim fldOld as Field

    on error resume next ' disable errorhandling
    for Each fldNew In rstNew
    set fldOld = rstOld.Fields(fldNew.Name)
    If Err.Number <> 0 then
    ' Field doesn't exist in old recordset
    else
    ' Field exist in old recordset
    End If
    next fldNew




    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured