How to Duplicate a Main Form and Its Subform Detail Records

J

John B

Dear All,
I am trying to duplicate a main form and its subform Detail records.
The subform detail record are duplicate in a correct way, but some field of
the main record not.
In particolar the field
!Mittente=Me!Mittente when added generate an error message like "run.time
error 438". And at this point I don't know what to do.

Many thanks for your help and your time. Regards
Giovanni


Private Sub btnDuplicate_Click()
Dim dbs As Database, Rst As Recordset
Dim F As Form

Set dbs = CurrentDb
Set Rst = Me.RecordsetClone
'On Error GoTo ErrorHandler

Me.Tag = Me![ProformaID]

With Rst
.AddNew
!Data = Me!Data
!Cliente = Me!Cliente
!Nazione = Me!Nazione
!Department = Me!Department
!Mittente = Me!Mittente

.Update
.Move 0, .LastModified
End With
Me.Bookmark = Rst.Bookmark

DoCmd.SetWarnings False
DoCmd.OpenQuery "Duplica Spedizione"
DoCmd.SetWarnings True

Me![Spedizione].Requery

SubExit:
Exit Sub
'ErrorHandler:
'MsgBox "The are no record to duplicate.", vbExclamation
'Resume SubExit
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top