Results 1 to 4 of 4
  1. #1
    dek is offline Novice
    Windows Vista Access 2007
    Join Date
    May 2011
    Posts
    4

    Subform : Copy selected fields from current row to new row

    Overview
    - Subform called 'Time'
    - Subform fields are named:
    • Well Ref - this is the well reference
      Start Time - self explanatory
      End Time - self explanatory
      Activity - combo box selection
      Quantity - integer value
      Another Field 1
      Another Field 2


      Another Field 3
      Another Field 4


    Problem:
    When entering the first record in the subform, the following data above is populated and takes some time due to network issues.

    To mitigate key strokes in new records and expedite the process in the subform, I would like to copy the previous subform record to the new records (when it has been selected / focused).

    The fields I would like to copy are:
    • Well Ref - this is the well reference
      Another Field 1
      Another Field 2
      Another Field 3
      Another Field 4


    Thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2007
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,600
    I do something like this. Form is in single record view. User clicks button to save record, they are prompted with option to continue with a new record that has same data. If they respond yes I set a variable with the current record ID, record is saved then goto new record. Code opens a recordset of the older record and I populate new record with values from the recordset.

    How you accomplish depends on your form setup. Sounds like subform is continuous or datasheet view and no save button? Since you have only 4 fields involved (mine is about 15), set 4 global variables with the values. Use the AfterUpdate event of each of the relevant controls to set the respective variable. Now how to trigger code to fill in the fields of new record with the variables - maybe the OnEnter or GotFocus event of the first field of the record.

  3. #3
    dek is offline Novice
    Windows Vista Access 2007
    Join Date
    May 2011
    Posts
    4
    June7,

    Thanks for your reply. I am having difficulty understanding your reply. Some VBA would be helpful to illustrate your solution.

    Confirmations:
    - 'ParentTable' [Captures the master details for the day, ie Asset, Date, etc]
    - 'ChildTable' [Captures the detailed activities for the day for the asset]

    - The main form [frmAsset] is a single record to capture data for 'ParentTable'
    - The subform of the main form [frmTime] is a continuous recordset which is linked frmAsset.

    I was hoping that there was a simple VBA solution to copy selected parts of the recordset of the last record of the frmTime.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2007
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,600
    Okay, here is what I was trying to suggest. In the header of subform code module declare variables such as: Dim strAF1 As String

    Then in AfterUpdate event for each control, name the controls something different from field name.
    Private Sub tbxAnotherField1_AfterUpdate()
    strAF1 = Me.tbxAnotherField1
    End Sub

    Then in GotFocus or Enter event of first control, maybe tbxWellRef:
    Private Sub tbxWellRef_GotFocus()
    If IsNull(Me.tbxAnotherField1) Then Me.tbxAnotherField1 = strAF1
    If IsNull(Me.tbxAnotherField2) Then Me.tbxAnotherField2 = strAF2
    If IsNull(Me.tbxAnotherField3) Then Me.tbxAnotherField3 = strAF3
    If IsNull(Me.tbxAnotherField4) Then Me.tbxAnotherField4 = strAF4
    End Sub

    The variables should hold the value of the first record until user types in another value and triggers the AfterUpdate event.
    Disclaimer: Code not tested, straight from my head to keyboard, on the fly.

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

Similar Threads

  1. Replies: 1
    Last Post: 10-13-2010, 12:40 PM
  2. Replies: 1
    Last Post: 08-17-2010, 02:33 PM
  3. Replies: 1
    Last Post: 07-14-2010, 01:34 PM
  4. Replies: 1
    Last Post: 03-13-2010, 08:38 PM
  5. Copying selected fields to a new record
    By Lyle Bitikofer in forum Forms
    Replies: 0
    Last Post: 12-13-2009, 04:01 PM

Tags for this Thread

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