+ Reply to Thread
Results 1 to 5 of 5

Thread: Update access tabel from excel

  1. #1
    Registered User
    Join Date
    08-12-2010
    Location
    India
    MS-Off Ver
    Excel 2002 - 2007
    Posts
    18

    Question Update access tabel from excel

    I new for working in access tables can any one access me how to update access table row from excel.
    Presently I successfully add the new records from excel to access (Got code from Google)- code as under

    Sub up1()
    Dim db As Database
    Dim rs As Recordset
    Dim r As Long
    Dim myDB As String
    Dim wks As Worksheet

    Sheets("Index-DSD").Select
    Range("A1").Select

    myDB = "C:\DVS\DVS_DSV.mdb"


    Set db = OpenDatabase(myDB)

    ' open the database
    Set rs = db.OpenRecordset("Index-DSD", dbOpenTable)

    ' get all records in a table
    r = 2 ' the start row in the worksheet
    Do While Len(Range("A" & r).Formula) > 0
    ' repeat until first empty cell in column A
    With rs
    .AddNew ' create a new record
    ' add values to each field in the record
    .Fields("VER_NO") = Range("A" & r).Value
    .Fields("TA") = Range("B" & r).Value
    .Fields("GEO") = Range("C" & r).Value
    .Fields("DB_GOLIVE_DATE") = Range("D" & r).Value
    .Fields("DTE_DATA_LOAD") = Range("E" & r).Value
    .Fields("STUDY_ID") = Range("F" & r).Value
    .Fields("DOC_NAME") = Range("G" & r).Value
    .Fields("SrcSheet") = Range("H" & r).Value
    .Fields("Changes") = Range("I" & r).Value
    .Fields("Keys") = Range("J" & r).Value
    .Fields("Keys Comm") = Range("K" & r).Value
    .Fields("Global") = Range("L" & r).Value
    .Fields("Structure") = Range("M" & r).Value
    .Fields("Variables") = Range("N" & r).Value
    .Fields("Value Lists") = Range("O" & r).Value
    ' add more fields if necessary...
    .Update ' stores the new record
    End With
    r = r + 1 ' next row
    Loop
    rs.Close
    Set rs = Nothing
    db.Close
    Set db = Nothing
    MsgBox "Appended " & r - 2 & " Records to your database", vbOKOnly, "Confirmation"
    End Sub

    What changes I have o do so it will also update the existing records which help me to avoid duplicates.

    Thanks in advance..

  2. #2
    Forum Contributor
    Join Date
    10-17-2007
    Location
    Washington, DC
    Posts
    103

    Re: Update access tabel from excel

    Maybe this is a dumb question, but why not just use the excel file itself as the source through linked table?

    If you really want it to be a table in access, use excel as the linked source and do a select * into to recreate the entire table, rather than worrying about incremental changes.

  3. #3
    Registered User
    Join Date
    08-12-2010
    Location
    India
    MS-Off Ver
    Excel 2002 - 2007
    Posts
    18

    Question Re: Update access tabel from excel

    Quote Originally Posted by psumvp View Post
    Maybe this is a dumb question, but why not just use the excel file itself as the source through linked table?

    If you really want it to be a table in access, use excel as the linked source and do a select * into to recreate the entire table, rather than worrying about incremental changes.
    Hi,

    I don't know how u call this is an dumb question or may be you not understand what i want to say.

    I have 10 user who going to add data in one database and their manager run report from that.
    Is it poosible that to use one access table linked to 10 user at the time??

    Insted of Abusive kindly help me on this.....

    Vish

  4. #4
    Forum Guru pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2010
    Posts
    5,150

    Re: Update access tabel from excel

    Hi vish2025

    Your first post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    can you please rectify the error
    regards pike

    If the solution helped please donate
    here to the RSPCA

    Sites worth visiting;

    J&R Solutions - royUK

    AJP Excel Information - Andy Pope

    Spreadsheet Toolbox

    VBA for smarties - snb

  5. #5
    Valued Forum Contributor
    Join Date
    04-23-2009
    Location
    IOWA
    MS-Off Ver
    2010 Professional
    Posts
    270

    Re: Update access tabel from excel

    Quote Originally Posted by psumvp View Post
    Maybe this is a dumb question, but why not just use the excel file itself as the source through linked table?

    If you really want it to be a table in access, use excel as the linked source and do a select * into to recreate the entire table, rather than worrying about incremental changes.
    I am going to reword this for you vish. He wasn't trying to be abusive.

    The "Maybe this is a dumb question" is his way of saying he is not sure of all the circumstances of your reasoning, therefore his suggestion may not fit your situation.

    The he goes on to give you a very good solution in my opinion.

    I personally see no reason for the excel file at all. Just make a split access database with a front end on each of the 10 computers. Use unbound forms for entry of data.

    P.S. Mods please don't scold me for posting on a thread that has a violation. I really just wanted to clarify that psumvp was not trying to be rude. Due to my limited time to visit this site I probably won't be able to check back later to see he fixed his code and then post.
    "I am not a rocket scientist, I am a nuclear engineer." - Split_atom18
    If my advice has been helpful to you, then please help me by clicking on the "Star" and adding to my reputation, Thanks!

+ 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.2.0