I have a form with several bound textboxes. These are routinely updated by User. The table in RecordSource for this form currently has 8 fields not shown on this form, but which occasionally need to be changed by User. For this I have created an "Advanced" commandbutton, which opens a child form with controls to display the remaining fields.
I tried using recordsetclone to put the child form on the same record and recordset as the main form, but when the child form is closed, the clone is updated. Then the main form gets a write conflict when it tries to update the same record.
I found a sample code on another question which I have modified slightly and uploaded here. Original by FishVal I think.
Child form 1 seems to do what I need. Forms 2 and 3 pass references to a control, not the underlying data. As I have currently 8 fields, these seem inappropriate.
1) Open form = "frmmain", and move to record 2. Change Text2 to something else, i.e. "R 2aaa".
Move to record 3. Press the UnDo button, and the record is returned to record 2 and that is undone. But navagating to a new record should save the changes. Why wasn't record 2 saved when record 3 displayed?
2) Open form = "frmmain", and move to record 2. Click the Child Form 1 button. Change to something else, i.e. "Record 2ccc". Press submit. Press the UnDo button. Why isn't the command 'Undo' available now. The recordset for frmChild1 is the same as for frmMain, and the record has not been moved to another record, so why is the Undo unavailable?
3) The procedure "Private Sub txb_BeforeUpdat e..." in the code for child1 saves .OldValue for this textbox in case the "Cancel" button is pushed. This should not be necessary, as .OldValue is the value in the record, and should remain until the record is updated. .Text would be lost after the textbox were updated. If I comment out this statement, and put a breakpoint in "Private Sub btnCancel_Click ()". Me.txb.OldValue is the updated textbox value, not the recordset original value. Why?
4) If new record is selected and then child1 used, when I press "Submit" I get message "Update or CancelUpdate without AddNew or Edit." AllowAdditions = Yes on both frmMain and frmChild1, so why this message?
OldBirdman
I tried using recordsetclone to put the child form on the same record and recordset as the main form, but when the child form is closed, the clone is updated. Then the main form gets a write conflict when it tries to update the same record.
I found a sample code on another question which I have modified slightly and uploaded here. Original by FishVal I think.
Child form 1 seems to do what I need. Forms 2 and 3 pass references to a control, not the underlying data. As I have currently 8 fields, these seem inappropriate.
1) Open form = "frmmain", and move to record 2. Change Text2 to something else, i.e. "R 2aaa".
Move to record 3. Press the UnDo button, and the record is returned to record 2 and that is undone. But navagating to a new record should save the changes. Why wasn't record 2 saved when record 3 displayed?
2) Open form = "frmmain", and move to record 2. Click the Child Form 1 button. Change to something else, i.e. "Record 2ccc". Press submit. Press the UnDo button. Why isn't the command 'Undo' available now. The recordset for frmChild1 is the same as for frmMain, and the record has not been moved to another record, so why is the Undo unavailable?
3) The procedure "Private Sub txb_BeforeUpdat e..." in the code for child1 saves .OldValue for this textbox in case the "Cancel" button is pushed. This should not be necessary, as .OldValue is the value in the record, and should remain until the record is updated. .Text would be lost after the textbox were updated. If I comment out this statement, and put a breakpoint in "Private Sub btnCancel_Click ()". Me.txb.OldValue is the updated textbox value, not the recordset original value. Why?
4) If new record is selected and then child1 used, when I press "Submit" I get message "Update or CancelUpdate without AddNew or Edit." AllowAdditions = Yes on both frmMain and frmChild1, so why this message?
OldBirdman
Comment