antonyx
Arsenal Supporter
- Local time
- Today, 22:41
- Joined
- Jan 7, 2005
- Messages
- 556
ok.. i think there is some problem with this code..basically there are a few listboxes and my user chooses a job and an invoice and when they are both highlighted they can 'add to invoice' or 'remove from invoice'
it successfully deletes a record but then on the same form session i get the following problem trying to add a record:
this is the error i am gettin on the above bold line..
am i not saving things properly..
Code:
Private Sub btnRemoveJob_Click()
Dim strSql As String
If Nz(Me.[lstInvoiceRefs], -1) = -1 Or Nz(Me.[lstInvoice], -1) = -1 Then
MsgBox "Please select a Job to remove!", vbExclamation
Exit Sub
End If
strSql = "DELETE FROM tblJobInvoice WHERE (((tblJobInvoice.fkJobRef)= '" & Me.[lstInvoice] & "'));"
DoCmd.SetWarnings False
DoCmd.RunSQL strSql
DoCmd.SetWarnings True
DoCmd.RunCommand acCmdSaveRecord
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
Me.lstNoInvoice.Requery
Me.lstInvoice.Requery
Me.lstInvoiceRefs.Requery
End Sub
it successfully deletes a record but then on the same form session i get the following problem trying to add a record:
Code:
Private Sub btnAddJob_Click()
If Nz(Me.[lstInvoiceRefs], -1) = -1 Or Nz(Me.[lstNoInvoice], -1) = -1 Then
MsgBox "Please select a Job AND an Invoice!", vbExclamation
Exit Sub
End If
[b]Me.txtjobref = Me.lstNoInvoice[/b]
Me.txtInvoiceRef = Me.lstInvoiceRefs
DoCmd.RunCommand acCmdSaveRecord
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
DoCmd.GoToRecord , , acNewRec
Me.lstNoInvoice.Requery
Me.lstInvoice.Requery
Me.lstInvoiceRefs.Requery
End Sub
this is the error i am gettin on the above bold line..
Run-time error '-2147352567 (80020009)':
Record in table 'tblJobInvoice' was deleted by another user.
am i not saving things properly..