Copy and paste on new record

jotaen

New member
Local time
Today, 10:56
Joined
May 5, 2019
Messages
6
Hi,

Is it possible to copy fields from a form and paste on next new record?
 
Hi. Yes. But, is this question related to this one? If so, what happened there?
 
Hi, no!

I give up that because I didn't manage to implement that solution.
 
Hi, no!

I give up that because I didn't manage to implement that solution.
I see. If so, you really don't need to start a new thread. You could simply reply back to the same thread and explain what you tried, so we can help you figure it out.


A simple way, or a straight forward way to copy records is by using:
Code:
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.RunCommand acCmdPasteAppend
I would suggest you consider posting a sample copy of your db with test in the other thread, so we can help you figure it out.
 
A simple way, or a straight forward way to copy records is by using:
Code:
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.RunCommand acCmdPasteAppend
I would suggest you consider posting a sample copy of your db with test in the other thread, so we can help you figure it out.

And is it possible to copy only specific fields? Kind like:

Code:
DoCmd.RunCommand acCmdCopy Me.FirstName
DoCmd.RunCommand acCmdPasteAppend Me.FirstName
 
And is it possible to copy only specific fields? Kind like:

Code:
DoCmd.RunCommand acCmdCopy Me.FirstName
DoCmd.RunCommand acCmdPasteAppend Me.FirstName
Hi. No, not with the "simple/straightforward" method I showed you. To get a "custom" copy, we'll need to use code. The link Paul gave you shows the code you'll need (or some of it).
 
I do this when rebooking workorders it save me having to enter some of the data that is realated to the last workorder This uses a combo box to select the record to be rebooked as below hope it helps



Code:
Dim m_Rrst As Recordset
Dim StrSQL As String
Dim IntLast As Integer
If Not IsNull(Me![CmdReBook]) Then
    IntLast = Me![CmdReBook]
If Not Me.NewRecord Then
    If Me.Dirty Then RunCommand acCmdSaveRecord
    DoCmd.GoToRecord acDataForm, Me.Name, acNewRec
End If
StrSQL = "SELECT * FROM tblWorkOrders WHERE [WorkOrderID]=" & Me![CmdReBook]
Set m_Rrst = CurrentDb.OpenRecordset(StrSQL)
If m_Rrst.RecordCount > 0 Then
    Me![CallType] = m_Rrst("CallType")
    Me![TypeofJob] = m_Rrst("TypeOfJob")
    Me![JobDetail] = m_Rrst("JobDetail")
    Me![CboClient] = m_Rrst("CustomerID")
        If Not IsNull(m_Rrst("SiteID")) Then
            Me![SiteID] = m_Rrst("SiteID")
            CboSite_AfterUpdate
        Else
            CmdJobAddress_Click
        End If
Me![LastJob] = IntLast
Me![CmdReBook] = Null
RunCommand acCmdSaveRecord
Me.Refresh
    End If
m_Rrst.Close
Set m_Rrst = Nothing
End If
 
Thank you all!

Sharing my solution.

I discover that I can put values in variables like so:

Code:
  Dim field As String
  field = Me.FirstName
  DoCmd.GoToRecord , , acNewRec
  Me.FirstName.value = field
 
Thank you all!

Sharing my solution.

I discover that I can put values in variables like so:

Code:
  Dim field As String
  field = Me.FirstName
  DoCmd.GoToRecord , , acNewRec
  Me.FirstName.value = field
Hi. Glad to hear you got it sorted out. Good luck with your project.
 
Hello!
You can use this code:


Private Sub TheTextYouWhantToCopy_DblClick(Cancel As Integer)
' the field you want to copy '
Me.[TheTextYouWhantToCopy].SetFocus
Me.[TheTextYouWhantToCopy].SelStart = 0
Me.[TheTextYouWhantToCopy].SelLength = Len(Me.[TheTextYouWhantToCopy])
DoCmd.RunCommand acCmdCopy
' the record where you want to paste '

[Forms]![001-00 - Home navigare]![NavigationSubform].[Form]![114-00 - NIR].SetFocus
DoCmd.GoToRecord , , acNewRec
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdPaste

End Sub
Hi. Welcome to AWF!
 
Code:
Private Sub TheTextYouWhantToCopy_DblClick(Cancel As Integer)

       '  the field you want to copy '

    Me.[TheTextYouWhantToCopy].SetFocus
    Me.[TheTextYouWhantToCopy].SelStart = 0
    Me.[TheTextYouWhantToCopy].SelLength = Len(Me.[TheTextYouWhantToCopy])
    DoCmd.RunCommand acCmdCopy

         ' the record where you want to paste '

    [Forms]![home]![NavigationSubform].[Form]!.SetFocus        ('you can change the path')
    DoCmd.GoToRecord , , acNewRec
    DoCmd.RunCommand acCmdSelectRecord
    DoCmd.RunCommand acCmdPaste

         ' or if you want to paste it in a specific field '

    [Forms]![home]![NavigationSubform].[Form]!.SetFocus        ('you can change the path')
    Me.[TheFieldWhereYouWantToPaste].SetFocus
    DoCmd.RunCommand acCmdPaste

End Sub
 

Users who are viewing this thread

Back
Top Bottom