I'm having some problems with Allen's routine:
1) a new entry is created, but nothing is duplicated there being the following error:
>> Run-time error '3061': Too few parameters. Expected 2.
Then the debugger kicks in and highlights:
>> DBEngine(0)(0).Execute strSql, dbFailOnError
I have made a change to the code as I actually have three subforms that have to be duplicated. I simply added two more update queries after the first one, but I can't check if this works because the first if+query sets the debugger off.
2) Despite the good explanation, I'm still a bit lost in what I am doing - namely the fields. I understood that first appear the field names (table) and then the form's control names (their source being the table field names identified first).
Code:
'Duplicate the main record: add to form's clone.
With Me.RecordsetClone
.AddNew
!LivroFisicoID = Me.LivroFisicoID
!SubGenero = Me.SubGenero
!AnoCriacao = Me.EscritoEm
.Update
Is this correct? Because, despite the duplication of the subforms not functioning, I assumed this part should be functioning (and it isn't).
3) I'm also having trouble with this part of the code:
Code:
'Save the primary key value, to use as the foreign key for the related records.
.Bookmark = .LastModified
lngID = !OrderID
My form is based on a table whose primary key is called ID, then it has relationships to three tables and the foreign IDs are called BookID in one, BookContentID in the other two. Should I set the foreign IDs to be called the same and then set the code as:
Code:
'Save the primary key value, to use as the foreign key for the related records.
.Bookmark = .LastModified
ID = !BookContentID
Thanks for anyone helping me understand this.
PS: sorry if I'm not very clear in my descriptions, not only is English not my native language, I'm also quite new to access.