This is my code, as I step through line by line, at the JBrec.Delete line it jumps directly to the deleteRecordsError error routine?
The "Ready to delete" message shows proper record to delete
I do have records in 3 other child tables linked to this delBid
I thought I had the delete working at one point.
Private Sub cmdDeleteRecords_Click()
'Goes directly to deleteRecordsError on JBrec.Delete
'CAN'T GET THE REQUERY FORM TO WORK
Dim cnt As Integer
Dim delBid As String
On Error GoTo deleteRecordsError
Stop
Set db = CurrentDb()
Set JBrec = db.OpenRecordset("JB_Jobs", dbOpenDynaset)
'delete this job and all related records
delstrSql = "JB_Deletesw = true and JB_JoborBid = false"
JBrec.FindFirst delstrSql
Do While Not JBrec.NoMatch
delBid = JBrec(0)
MsgBox " Ready to delete bid " & strQuote & delBid & strQuote
JBrec.Delete
MsgBox "Deleted " & strQuote & delBid & strQuote & " Bid record"
JBrec.FindFirst delstrSql
If JBrec.NoMatch Then
MsgBox "findnextfirst Bid is no match"
Requery
End If
Loop
If JBrec.NoMatch Then
MsgBox "There are no Bid records to delete"
Call Form_Close
End If
Exit Sub
deleteRecordsError:
MsgBox "deleteRecordsError"
End Sub
Private Sub OLDcmdDeleteRecords_Click()
'CAN'T GET THE REQUERY FORM TO WORK
Dim cnt As Integer
Dim delBid As String
On Error GoTo deleteRecordsError
Stop
Set db = CurrentDb()
Set JBrec = db.OpenRecordset("JB_Jobs", dbOpenDynaset)
Set JBTrec = db.OpenRecordset("JBT_EmpTime", dbOpenDynaset)
Set JBMrec = db.OpenRecordset("JBM_JobMatList", dbOpenDynaset)
Set JBOrec = db.OpenRecordset("JBO_JobOverheads", dbOpenDynaset)
'delete this job and all related records
delstrSql = "JB_Deletesw = true and JB_JoborBid = false"
JBrec.FindFirst delstrSql
Do While Not JBrec.NoMatch
delBid = JBrec(0)
'Call DeleteAllChildRecords
MsgBox " Ready to delete bid " & strQuote & delBid & strQuote
'MsgBox "Found matching Job record"
JBrec.Delete
MsgBox "Deleted " & strQuote & delBid & strQuote & " Bid record"
JBrec.FindFirst delstrSql
If JBrec.NoMatch Then
MsgBox "findnextfirst Bid is no match"
Requery
End If
Loop
If JBrec.NoMatch Then
MsgBox "There are no Bid records to delete"
Call Form_Close
End If
Exit Sub
deleteRecordsError:
MsgBox "deleteRecordsError"
End Sub
The "Ready to delete" message shows proper record to delete
I do have records in 3 other child tables linked to this delBid
I thought I had the delete working at one point.
Private Sub cmdDeleteRecords_Click()
'Goes directly to deleteRecordsError on JBrec.Delete
'CAN'T GET THE REQUERY FORM TO WORK
Dim cnt As Integer
Dim delBid As String
On Error GoTo deleteRecordsError
Stop
Set db = CurrentDb()
Set JBrec = db.OpenRecordset("JB_Jobs", dbOpenDynaset)
'delete this job and all related records
delstrSql = "JB_Deletesw = true and JB_JoborBid = false"
JBrec.FindFirst delstrSql
Do While Not JBrec.NoMatch
delBid = JBrec(0)
MsgBox " Ready to delete bid " & strQuote & delBid & strQuote
JBrec.Delete
MsgBox "Deleted " & strQuote & delBid & strQuote & " Bid record"
JBrec.FindFirst delstrSql
If JBrec.NoMatch Then
MsgBox "findnextfirst Bid is no match"
Requery
End If
Loop
If JBrec.NoMatch Then
MsgBox "There are no Bid records to delete"
Call Form_Close
End If
Exit Sub
deleteRecordsError:
MsgBox "deleteRecordsError"
End Sub
Private Sub OLDcmdDeleteRecords_Click()
'CAN'T GET THE REQUERY FORM TO WORK
Dim cnt As Integer
Dim delBid As String
On Error GoTo deleteRecordsError
Stop
Set db = CurrentDb()
Set JBrec = db.OpenRecordset("JB_Jobs", dbOpenDynaset)
Set JBTrec = db.OpenRecordset("JBT_EmpTime", dbOpenDynaset)
Set JBMrec = db.OpenRecordset("JBM_JobMatList", dbOpenDynaset)
Set JBOrec = db.OpenRecordset("JBO_JobOverheads", dbOpenDynaset)
'delete this job and all related records
delstrSql = "JB_Deletesw = true and JB_JoborBid = false"
JBrec.FindFirst delstrSql
Do While Not JBrec.NoMatch
delBid = JBrec(0)
'Call DeleteAllChildRecords
MsgBox " Ready to delete bid " & strQuote & delBid & strQuote
'MsgBox "Found matching Job record"
JBrec.Delete
MsgBox "Deleted " & strQuote & delBid & strQuote & " Bid record"
JBrec.FindFirst delstrSql
If JBrec.NoMatch Then
MsgBox "findnextfirst Bid is no match"
Requery
End If
Loop
If JBrec.NoMatch Then
MsgBox "There are no Bid records to delete"
Call Form_Close
End If
Exit Sub
deleteRecordsError:
MsgBox "deleteRecordsError"
End Sub