Unable to create duplicate record on subform (1 Viewer)

nika.duncan

Registered User.
Local time
Yesterday, 23:30
Joined
Sep 23, 2013
Messages
10
Hi All,
I am trying to create duplicate records from a main form frmManagers which has a subform frmSubMeasure. I have placed the duplicate button on the main form. It creates a duplicate of the main form data and gives me the option to add new record to the sub. I want the duplicate to be created on the sub form for me to just edit the scores.

I don't know how to pass the sub form data to be duplicated I thought the append query which I used would update the tblSubMeasure table which created the subform frmSubMeasure.
In the sub the append query do update the form with the new MeasureID from the mainform and the form is available to enter new data. I want the subform data to be duplicated as well

In the query I included all the fields from the tblSubMeasure table and this is appended to the same table tblSubMeasure and I place a tag on the MeasureID using "[Forms]![frmManagers].[Tag]"

I have outlined the code below for anyone to have a look and let me know where I am going wrong.

Code:
Private Sub btnDuplicate_Click()

Dim dbs As DAO.Database, Rst As DAO.Recordset
Dim F As Form

'Return Database variable pointing to current database.
Set dbs = CurrentDb
Set Rst = Me.RecordsetClone

On Error GoTo Err_btnDuplicate_Click

'Tag property to be used later by the append query.
Me.Tag = Me![MeasureId]


'Add new record to end of Recordset Object.

With Rst
.AddNew
!MUserLoginID = Me!MUserLoginID
!MeasureName = Me!MeasureName
!MPositonNumber = Me!MPositonNumber
!MeasureScore = Me!MeasureScore
'!MeasureTotal = Me!MeasureTotal
!MAssBDate = Me!MAssBDate
!MAssEDate = Me!MAssEDate



.Update
.Move 0, .LastModified

End With

Me.Bookmark = Rst.Bookmark

DoCmd.SetWarnings False
DoCmd.OpenQuery "Duplicate Measure Details"   ' Should perform an append query on tblSubMeasure and update the same table 
DoCmd.SetWarnings True

'Requery the subform
Me![frmSubMeasure].Requery

'!SubMeasureName = Me!SubMeasureName  'fields from tblSubMeasure not sure how to pass them
'!SubMeasureDesp = Me!SubMeasureDesp
Exit_btnDuplicate_Click:
Exit Sub

Err_btnDuplicate_Click:
Resume Exit_btnDuplicate_Click:
End Sub
 

Users who are viewing this thread

Top Bottom