Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

carrying over data to new record 3

Status
Not open for further replies.

Clawd

Technical User
Nov 29, 2000
4
US
I'm trying to set up an inventory form so that - when I click a command btn (to add a new record to this purchase order), it will add a new record with some fields being the same as the previous record. I'd rather do this in VB than a macro.

Thanks
 
I did a similar thing for an inventory database that I wrote. Here is the code...

Private Sub btnlastenry_Click()
DoCmd.GoToRecord , , acNewRec
Dim rec As Recordset
Set rec = CurrentDb.OpenRecordset("outgoingorders", dbOpenDynaset)
rec.MoveLast

Me.TrackingNumber = rec!TrackingNumber
Me.Address = rec!Address
Me.City = rec!City
Me.State = rec!State
Me.Zip = rec!Zip
Me.Namebox = rec!Name
Me.HowShipped = rec!HowShipped
Me.ShippedTo = rec!ShippedTo
Me.sjid = rec!sjid
Me.DatetoRecall = rec!DatetoRecall
Me.SaleID = rec!SaleID
Me.receivedback = rec!receivedback
Me.shipby = rec!shipby

rec.Close
Set rec = Nothing
Me.ItemNum.SetFocus
End Sub

Hope it helps

Mike Rohde
rohdem@marshallengines.com
 
here is a new cpommand button to do what you need.

-----------------------------------------
Private Sub Command6_Click()
On Error GoTo Err_Command6_Click

Dim X, Y, Z As Variant
' get previous data from record and save to temp variables
X = Me!Field1
Y = Me!Field2
Z = Me!Field3

' Create a new record
DoCmd.GoToRecord , , acNewRec

' Then put temp data back into fields of new record
Me!Field1 = X
Me!Field2 = Y
Me!Field3 = Z

Exit_Command6_Click:
Exit Sub

Err_Command6_Click:
MsgBox Err.Description
Resume Exit_Command6_Click

End Sub
-----------------------------------------



DougP, MCP
dposton@universal1.com

Ask me how Bar-codes can help you be more productive.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top