If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Goto new record of subform and force a save using the default values ?
Experts:
A bound form X contains a bound subform Y and they are linked via Child/Master settings. UF is an unbound form that contains subform X and a command button "New" When new is clicked the event handler does Me.X.Field1.DefaultValue = """New Field 1""" Me.X.Field2.DefaultValue = """New Field 2""" Me.X.Field3.DefaultValue = """New Field 3""" Me.X.SetFocus DoCmd.GoToRecord , , acNewRec The new record is gone to, and the default values are shown as expected. But the record does not get written to tblX. How can I force the new record to get written to the table ? Thanks, |
#2
|
|||
|
|||
Goto new record of subform and force a save using the default values ?
You could dirty the record by assigning the existing (default) value to a
control, and then saving: With Me.X.Form !Field1 = !Field1 .Dirty = False End With If you just wanted a new record added, it might be easier to AddNew to its RecordsetClone, and then display that record: Dim rs As DAO.Recordset With Me.X.Form Set rs = .RecordsetClone rs.AddNew rs!Field1 = "New Field 1" rs!Field2 = "New Field 2" 'etc rs.Update .Bookmark = rs.LastModified Set rs = Nothing End With -- 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. "Richard" wrote in message oups.com... Experts: A bound form X contains a bound subform Y and they are linked via Child/Master settings. UF is an unbound form that contains subform X and a command button "New" When new is clicked the event handler does Me.X.Field1.DefaultValue = """New Field 1""" Me.X.Field2.DefaultValue = """New Field 2""" Me.X.Field3.DefaultValue = """New Field 3""" Me.X.SetFocus DoCmd.GoToRecord , , acNewRec The new record is gone to, and the default values are shown as expected. But the record does not get written to tblX. How can I force the new record to get written to the table ? Thanks, |
Thread Tools | |
Display Modes | |
|
|