Replace Null field with previous record value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Craig Martin
    New Member
    • Jun 2006
    • 6

    Replace Null field with previous record value

    I get a text file every day that has Customer ID and Product ID. The customer ID is only in the first record. I need to replicate the customer ID into each field relating to his products. Find and replace box works fine but I have hundreds to do each day. I need a to do it in the code area on "on open" or some other automatic way.
    Please help me with my near vission.
    Thanks,
    Craig
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Erm you haven't mentioned what packages/programs you are using/you have available or what operating system you are using.

    Comment

    • Craig Martin
      New Member
      • Jun 2006
      • 6

      #3
      Originally posted by Banfa
      Erm you haven't mentioned what packages/programs you are using/you have available or what operating system you are using.
      I use access XP on windows xp home. The file that comes to me is a .csv. I have it linked to my database and append to a table that requires the customer ID filled in - it's the index for the product ID.

      Hope that is the info you were asking for.

      Thanks,

      Craig

      Comment

      • Craig Martin
        New Member
        • Jun 2006
        • 6

        #4
        Banfa,
        Thanks For responding

        Just got the answer. Tested it and works great.

        Dim rstThis as RecordSet
        Dim varField2 as Variant

        Set rstThis = CurrentDB.OpenR ecordset("11-SWBACKORDS-test") ' or whatever it is called

        With rstThis
        .MoveLast
        .MoveFirst
        If .RecordCount Then
        Do Until .EOF
        If Len(nz(!Field2, vbNullString)) Then
        varField2 = !Field2
        Else
        .Edit
        !Field2 = varField2
        .Update
        End If
        .MoveNext
        Loop
        End If
        .Close
        End With
        Set rstThis = Nothing

        Thanks again,

        Craig

        Comment

        Working...