This example duplicates the current record in the form, by copying it to the
form's RecordsetClone. It assumes that any of the contorls that have a
number in their Tag property are controls that are bound directly to a
field.
Dim rs As DAO.Recordset
Dim ctl As Control
Dim strField As String
If Me.Dirty Then 'Save first
Me.Dirty = False
End If
If Me.NewRecord Then 'Make sure there is a record.
MsgBox "Select a record to duplicate"
Else
'Duplicate to the form's clone set
Set rs = Me.RecordsetClone
rs.AddNew
For Each ctl In Me.Contorls
If IsNumeric(ctl.Tag) Then
strField = ctl.ControlSource
rs(strField) = ctl.Value
End If
Next
rs.Update
'Make that record the current one.
Me.Bookmark = rs.LastModified
End If
Set rs = Nothing
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Saintor" <sa******@REMOVETHIShotmail.com> wrote in message
news:Fx********************@weber.videotron.net...
Each control on my form has a number 0-9 in the TAG property. What I need
to do is to duplicate a record, but not all controls, only the ones up to
the value stored in the TAG property. It should look like.
...
Set db1 = CurrentDb()
Set rs1 = db1.OpenRecordset("tblLang")
DoCmd.OpenForm "MyForm", acDesign
Set frm = forms("MyForm")
rs1.AddNew
For Each ctl In frm.Controls
If ctl.tag <=TAG_VALUE
rs1!ctl.controlsource = ctl.value 'not sure about this one
rs1.Update
rs1.Bookmark = rs1.LastModified
end if
Next ctl
...
But opening a form in acDesign mode won't work in a runtime environment,
right? What are my options? TIA.