New Record on Mainform but NOT on Subform

Clarabella

New member
Local time
Today, 09:29
Joined
Nov 30, 2012
Messages
5
Hi everyone,

I have a form with tabbed controls: The first tab is the mainform and the second tab is a subform. Mainform and subform are related one-to-many.

I have a button to duplicate the data in the mainform (changing the ID, of course) and it works well BUT automatically a new record is also added in the subform, which I don't want at all.

I am using the code provided here
allenbrowne.com/ser-57.html
but I am NOT using the part related to the subform.

---------
Private Sub cmdDupe_Click() 'On Error GoTo Err_Handler 'Purpose: Duplicate the main form record and related records in the subform. Dim strSql As String 'SQL statement. Dim lngID As Long 'Primary key value of the new record. 'Save any edits first If Me.Dirty Then Me.Dirty = False End If 'Make sure there is a record to duplicate. If Me.NewRecord Then MsgBox "Select the record to duplicate." Else 'Duplicate the main record: add to form's clone. With Me.RecordsetClone .AddNew !CustomerID = Me.CustomerID !EmployeeID = Me.EmployeeID !OrderDate = Date 'etc for other fields. .Update 'Save the primary key value, to use as the foreign key for the related records. .Bookmark = .LastModified lngID = !OrderID 'CUT - NOT USED - Duplicate the related records: append query. End If 'Display the new duplicate. Me.Bookmark = .LastModified End With End If
----------
I guess that it makes sense that after update of the mainform a new record on the subform is added as well, but I don't necessarily want to add it immediately.

Would it help if I disabled the subform while adding the new record on the Mainform?

This is driving me crazy, really.
Before I used to have separate forms and everything was working fine, now with the new gui I have this unwanted behaviour.
I think it depends on the fact that if the subform is open in the nearby tab, then the new record must be added, but I want to prevent this.

Any suggestions?

Thanks!
Erika
 

Users who are viewing this thread

Back
Top Bottom