Add new record into Subform

  • Thread starter Thread starter yuenyi1314
  • Start date Start date
Y

yuenyi1314

Dear,

Could anybody coach me how to add a new editable record
into a related subform from main form? and How to move the
current record pointer to ,say, last record? It is because
not much discussed with this.

Regards,
Hing
 
To programmatically add a new record, use AddNew and Update on the
RecordsetClone of your subform.
Dim rs As DAO.Recordset
Set rs = Me.[NameOfYourSubformControlHere].Form.RecordsetClone
rs.AddNew
rs!SomeField = xxxx
rs!AnotherField = 9999
rs!SomeDate = Date
'etc
rs.Update
Set rs = Nothing

To make the last record in the subform the current record:
Dim frm As Form
Set frm = Me.[NameOfYourSubformControlHere].Form
With frm.RecordsetClone
If .RecordCount > 0 Then
.MoveLast
frm.Bookmark = .Bookmark
End If
End With
Set frm = Nothing

Unfortunately, all the previous records scroll out the top, as Access makes
your selected record the first visible one.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

message
news:[email protected]...
 
Back
Top