does the check box cause double entry?

1jet

Registered User.
Local time
Today, 23:15
Joined
Sep 15, 2008
Messages
117
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

contractsvk7.jpg

By f22a at 2008-09-30

contracts2to9.jpg

By f22a at 2008-09-30

contracts3hn6.jpg

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
 
Code:
strSQL = " INSERT INTO tblEmployeeContract ( [Contract Type] , Used ) " & _
         contracttype, In_USe ;

Try this sql instead
 
Nope...didn't help sorry
 
maybe your sql statement is saving a record, and your form (if its bound) is ALSO saving the same record
 
Hmmm....yeah the form is bound to the table.
So I guess I should just run a save command instead of the append query?
I'll be giving it a go now...
 
Yep Gemma thanks for that.
The SQL query is no longer necessary and I'm only using a save command now.
 

Users who are viewing this thread

Back
Top Bottom