Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Brookline, Massachusetts, USA
    Posts
    606
    Thanks
    17
    Thanked 0 Times in 0 Posts

    Replicating field data (2003 SP3)

    I want to duplicate the data in a field in the next twenty records. I vaguely remember a post long ago that there was an easy way to do this in a form, but can't find it. I know I can use an Update Query but was curious about any other method.
    HH

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Replicating field data (2003 SP3)

    You can copy the value of a field from the previous record by clicking in the field and pressing Ctrl+' (apostrophe).

    If you want to copy the values of one or more fields automatically, you can use the technique described in MSKB article How to fill a record with data from a previous record automatically in Access 2000 and 2002 and Office Access 2003.

  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Replicating field data (2003 SP3)

    Hi Howard, I use the Click event of a button in the form footer of a continuous form whose record source is a query based on the Previsioni table.
    <pre>Private Sub Command130_Click()
    On Error GoTo Err_Command130_Click
    Dim strInput As String, strMsg As String, strSQL As String

    If Me.Dirty Then
    RunCommand acCmdSaveRecord
    End If


    strMsg = "How many times?"
    strInput = InputBox(Prompt:=strMsg, _
    Title:="Copy the value down the column", XPos:=2000, YPos:=2000)

    strSQL = "UPDATE Previsioni SET [" & Screen.PreviousControl.Name & "] = " & Screen.PreviousControl.Value & _
    " WHERE previsioni.Giorno = #" & Format(Me!Giorno, "mm/dd/yyyy") & _
    "# And previsioni.Ora between (" & Me!Ora & "+1) and (" & Me.Ora & "+" & strInput & ")"

    CurrentDb.Execute strSQL


    Screen.PreviousControl.SetFocus

    Exit_Command130_Click:
    Exit Sub

    Err_Command130_Click:
    MsgBox Err.Description
    Resume Exit_Command130_Click


    End Sub</pre>


  4. #4
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Brookline, Massachusetts, USA
    Posts
    606
    Thanks
    17
    Thanked 0 Times in 0 Posts

    Re: Replicating field data (2003 SP3)

    Thanks Hans. CTRL+' was what I was looking for.
    Best,
    HH

  5. #5
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Brookline, Massachusetts, USA
    Posts
    606
    Thanks
    17
    Thanked 0 Times in 0 Posts

    Re: Replicating field data (2003 SP3)

    Thanks for the reply. Your code is fine for a large amount of data, but is overkill for my current needs. HansV's reply (see above) using CTRL+' worked fine.
    HH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •