+ Reply to Thread
Results 1 to 8 of 8

.Addnew with .Update still overwrites record - how do I change this?

  1. #1
    Registered User
    Join Date
    03-08-2012
    Location
    Sweden
    MS-Off Ver
    2010
    Posts
    5

    .Addnew with .Update still overwrites record - how do I change this?

    Hello, I have som problem with a temporary recordset I'm creating. I've searched quite a lot and I understand that it is something wrong with my code but I haven't seen a straightforward answer to my problem. Here is the code:

    The values for the two rows are unique

    PHP Code: 
         With rs_ar
         
            
            
    .AddNew
            
    .Fields("X") = Prognosar_t_1
            
    .Fields("Y") = P_t_1_string!P_t_1
            
    .Update
            
            
    .AddNew
            
    .Fields("X") = Prognosar_t_2
            
    .Fields("Y") = P_t_2_string!P_t_2
            
    .Update
        
        End With 
    Thanks for your consideration
    Last edited by Luonas; 03-09-2012 at 10:25 AM. Reason: Solved

  2. #2
    Forum Contributor tkowal's Avatar
    Join Date
    11-20-2010
    Location
    Miami, Fl
    MS-Off Ver
    Excel 2010
    Posts
    150

    Re: .Addnew with .Update still overwrites record - how do I change this? code posted

    Your code above works fine form me in both ADO and DAO inserting into an access database

    Try this.....
    Please Login or Register  to view this content.

  3. #3
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: .Addnew with .Update still overwrites record - how do I change this? code posted

    How are you testing the values stored in the recordset?
    Good luck.

  4. #4
    Registered User
    Join Date
    03-08-2012
    Location
    Sweden
    MS-Off Ver
    2010
    Posts
    5

    Re: .Addnew with .Update still overwrites record - how do I change this? code posted

    Thanks for the replys, I began suspecting as much. I stored the values in a temporary recordset (so when I try to print them in a table it does work).

    The way I test the values is by printing them in an word report-table (I'm doing all of this from word) so the problem is probably this part (because as far as I know a temporary recordset isn't any different from a more permanent one?)

    Im using this function to output the values:

    PHP Code: 
      txt rs_ar.GetString(adClipString2ColumnDelimeter:=vbTabRowDelimeter:=vbCrLfNullExpr:="<null>"

  5. #5
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: .Addnew with .Update still overwrites record - how do I change this? code posted

    And you get two rows in your output that are both the same?

  6. #6
    Registered User
    Join Date
    03-08-2012
    Location
    Sweden
    MS-Off Ver
    2010
    Posts
    5

    Re: .Addnew with .Update still overwrites record - how do I change this? code posted

    Nope, I just get last added row as an ouput. And unfortunently

  7. #7
    Registered User
    Join Date
    03-08-2012
    Location
    Sweden
    MS-Off Ver
    2010
    Posts
    5

    Re: .Addnew with .Update still overwrites record - how do I change this? code posted

    Quote Originally Posted by OnErrorGoto0 View Post
    In that case you probably just need to use .MoveFirst before you use the GetString.
    And that was exactly what was needed. Thanks! A simple solution but I was bogged down in my thinking.

  8. #8
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: .Addnew with .Update still overwrites record - how do I change this? code posted

    Glad to help. Please don't forget to mark the thread solved.

+ 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