+ Reply to Thread
Results 1 to 8 of 8

ADODB Record Upate

Hybrid View

  1. #1
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: ADODB Record Upate

    Something like this

        rs.Open "Select [Job Number], [Inspection Date], [SHIP DATE] " & _
                "From FinalInspection " & _
                "Where((([Job Number])=1));", Db, adOpenDynamic, adLockOptimistic
                                   '< '1' for text field in where clause
                                   '<  1  for numeric field in where clause
        r = 2 ' the start row in the worksheet
       
        With rs
            If Not .EOF Then '<==  ' Unique id exisits
                .Fields("Inspection Date") = Range("B" & r).Value
                .Fields("SHIP DATE") = Range("C" & r).Value
                .Update
            Else '<==  ' Unique id does not exisits
                .AddNew ' create a new record
                ' add values to each field in the record
                .Fields("Job Number") = Range("A" & r).Value  ' Unique Key
                .Fields("Inspection Date") = Range("B" & r).Value
                .Fields("SHIP DATE") = Range("C" & r).Value
            End If
          .Close
        End With
        Set rs = Nothing
        Db.Close
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  2. #2
    Registered User
    Join Date
    09-05-2012
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: ADODB Record Upate

    Mike,

    Thank you. Exactly what I was trying to do.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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