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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy most recent record

Status
Not open for further replies.

debbieg

Technical User
Dec 2, 2002
190
US
Here's my tables that I have a question about:

tblEmployee
EmpNo
LastName
FirstName
MI
DateHired

tblDeptPay
EmpNo
DateEffective
HomeDept
ShiftCode
HourlyPayRate

I am creating a database to track payroll hours. Since an employee can change their Dept, ShiftCode, and HourlyPayRate, I figured I needed to have this information separate.

I have a form based on tblEmployee to display the information. Then I have a subform on this form based on tblDeptPay. I'm doing calculations or reporting on the most current information, so when I add a new record all of the fields need to be completed on the subform. For example, if an employee gets a pay raise, the HomeDept and ShiftCode need to be entered on the new record.

Is there a way to copy the most recent record so the user only has to change the appropriate information?

Thanks for any help anyone can provide.

Debbie
 
I answered my own question. For those who might have the same question, here's what worked for me.

This works since the first record is the most recent.
Code:
Private Sub cmdAdd_Click()
    DoCmd.GoToRecord , , acFirst
    DoCmd.RunCommand acCmdSelectRecord
    DoCmd.RunCommand acCmdCopy
    Me.AllowAdditions = True
    DoCmd.RunCommand acCmdPasteAppend
End Sub
Hope this helps someone else.

Debbie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top