comicwizard
Registered User.
- Local time
- Today, 02:35
- Joined
- Mar 24, 2011
- Messages
- 15
I have a form with a sub form. when a record is choosen in a combo box the sub form is filled out with a record.
what I am trying to do is have a button that will copy that record to a history table then delete it off the the main table.
I cheeted by using the wizard to get the code to delete the record but I am having troubles modifying the code to copy that record to the history table. Here is the code below. I have tried to insert code in several places but it just errors out.
'------------------------------------------------------------
' Master_tbl_sub_fm
'
'------------------------------------------------------------
Function Master_tbl_sub_fm()
On Error GoTo Master_tbl_sub_fm_Err
With CodeContextObject
On Error Resume Next
DoCmd.GoToControl Screen.PreviousControl.Name
Err.Clear
If (Not .Form.NewRecord) Then
DoCmd.RunCommand acCmdDeleteRecord
End If
If (.Form.NewRecord And Not .Form.Dirty) Then
Beep
End If
If (.Form.NewRecord And .Form.Dirty) Then
DoCmd.RunCommand acCmdUndo
End If
If (.MacroError <> 0) Then
Beep
MsgBox .MacroError.Description, vbOKOnly, ""
End If
End With
Master_tbl_sub_fm_Exit:
Exit Function
Master_tbl_sub_fm_Err:
MsgBox Error$
Resume Master_tbl_sub_fm_Exit
End Function
what I am trying to do is have a button that will copy that record to a history table then delete it off the the main table.
I cheeted by using the wizard to get the code to delete the record but I am having troubles modifying the code to copy that record to the history table. Here is the code below. I have tried to insert code in several places but it just errors out.
'------------------------------------------------------------
' Master_tbl_sub_fm
'
'------------------------------------------------------------
Function Master_tbl_sub_fm()
On Error GoTo Master_tbl_sub_fm_Err
With CodeContextObject
On Error Resume Next
DoCmd.GoToControl Screen.PreviousControl.Name
Err.Clear
If (Not .Form.NewRecord) Then
DoCmd.RunCommand acCmdDeleteRecord
End If
If (.Form.NewRecord And Not .Form.Dirty) Then
Beep
End If
If (.Form.NewRecord And .Form.Dirty) Then
DoCmd.RunCommand acCmdUndo
End If
If (.MacroError <> 0) Then
Beep
MsgBox .MacroError.Description, vbOKOnly, ""
End If
End With
Master_tbl_sub_fm_Exit:
Exit Function
Master_tbl_sub_fm_Err:
MsgBox Error$
Resume Master_tbl_sub_fm_Exit
End Function