Trying to copy record for use in a new one.

parkerjallen

Registered User.
Local time
Yesterday, 23:06
Joined
Nov 13, 2012
Messages
18
I'm trying to add a button that will copy a bunch of the fields and have it ready for the next record, as they will be doing a lot of the same tests in a row. Here is the code I have.

Code:
Private Sub CopyButton_Click()
Dim vfpn As String
Dim vcon1 As String
Dim vcon2 As String
Dim vmode As String

Set vfpn = Nz(Me.FullPartNumber, "")
Set vcon1 = Nz(Me.pCon1, "")
Set vcon2 = Nz(Me.pCon2, "")
Set vmode = Nz(Me.pMode, "")

DoCmd.GoToRecord , , acLast

Me.FullPartNumber = Nz(vfpn, "")
Me.pCon1 = Nz(vcon1, "")
Me.pCon2 = Nz(vcon2, "")
Me.pMode = Nz(vmode, "")
End Sub

The button doesn't even do anything. What terribly simple thing have I missed? :(
 
Replace:
Code:
DoCmd.GoToRecord , , acLast

with

Code:
DoCmd.GoToRecord , , [COLOR=red]acNewRec[/COLOR]

Your code as is takes the copied values and placing them back into the last record. If you are already on the last record, you wouldn't see any change.

If you where on any other record, the last record would have the four values replaced with values from the current record.
 
Now upon clicking the button, it says Compile error: object required

It highlights the Private Sub line in yellow, and also highlights the vfpn, after Set.
 
Ok this is a guess, but I don't use "Set" for strings. Try removing the 4 Sets in your code.
 

Users who are viewing this thread

Back
Top Bottom