Hi all,
I've got a simple form that either "saves" or "appends a new" contract type into a small table. The table has a "yes or no" check box as well as the form. Has anyone had a strange problem where your "INSERT INTO" query appends two of the same row?
I've got pics and my code below.
Cheers
By f22a at 2008-09-30
By f22a at 2008-09-30
By f22a at 2008-09-30
I've got a simple form that either "saves" or "appends a new" contract type into a small table. The table has a "yes or no" check box as well as the form. Has anyone had a strange problem where your "INSERT INTO" query appends two of the same row?
I've got pics and my code below.
Cheers
By f22a at 2008-09-30
By f22a at 2008-09-30
By f22a at 2008-09-30
Code:
Function vbaSaveNewContract()
Dim strSQL As String
Dim frm As Form
Dim contracttype As Control
Dim in_use As Control
Set frm = Forms!frmContract
Set contracttype = frm.txtContractName
Set in_use = frm.chkUsed
DoCmd.SetWarnings False
strSQL = " INSERT INTO tblEmployeeContract ( [Contract Type] , Used ) " & _
" SELECT Forms!frmContract!txtContractName, Forms!frmContract!chkUsed ; "
DoCmd.RunSQL strSQL
MsgBox "Changes have been saved."
Forms!frmContract!cboSelectContract.Value = ""
'Me!cboSelectContract.SetFocus
'Me!cmdCreateNew.SetFocus
Me!cmdCloseFormContract.SetFocus
Forms!frmContract!cboSelectContract.Enabled = True
Forms!frmContract!txtContractName.Enabled = False
Forms!frmContract!chkUsed.Enabled = False
Forms!frmContract!cmdSave.Enabled = False
Forms!frmContract!cmdSaveNew.Enabled = False
Forms!frmContract!cmdUndo.Enabled = False
DoCmd.Requery ""
DoCmd.SetWarnings True
strSQL = ""
Set frm = Nothing
Set contracttype = Nothing
Set in_use = Nothing
End Function