Results 1 to 2 of 2
  1. #1
    GeorgeJ is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    67

    Changing a record all at once

    Suppose I have a table with Field1, Field2 and …Field5. I want to give the first record the values of the second record for all fields. The following works

    Dim db as DAO.database, RST as dao.recordset
    Dim S1$,S2$,S3$,S4$,S5$
    Set db = currentdb
    Set rst = db.openrecordset(“MyTable”,dbopendynaset)
    Rst.movefirst
    Rst.movenext
    S1$ = rst!Field1
    S2$ = rst!Field2
    S3$ = rst!Field3
    S4$ = rst!Field4
    S5$ = rst!Field5
    Rst.moveprevious
    Rst.edit


    Rst!Field1 = s1$
    Rst!Field2 = s2$
    Rst!Field3 = s3$
    Rst!Field4 = s4$
    Rst!Field5 = s5$
    Rst.update


    My question is, is there a shorter more direct way to do it?

    Thanks in advance

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Why do you need to do this? Why would you always set 'first' record with values of 'second' record?

    A 'more direct' method would likely involve an SQL UPDATE action statement.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Changing Record values with VB
    By RevBlueJeans in forum Access
    Replies: 3
    Last Post: 03-20-2015, 08:32 AM
  2. duplicating a record but changing a field value.
    By Jrw76 in forum Programming
    Replies: 7
    Last Post: 01-08-2014, 02:48 PM
  3. Replies: 1
    Last Post: 02-20-2013, 01:30 PM
  4. Changing Misspelled Record
    By tylerg11 in forum Access
    Replies: 5
    Last Post: 09-27-2011, 10:15 AM
  5. Changing the record source in a form
    By lmichaud in forum Forms
    Replies: 1
    Last Post: 07-09-2006, 09:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums