G
Guest
I have the following:
Dim response As String
Dim findrecord As Integer
Dim strsaw As String
Dim strsql As Variant
strsaw = Saw_ID
response = MsgBox("If you continue closing this form, the saw
performance" & vbCrLf & _
"you were working on will be deleted from the database." &
vbCrLf & _
"Are you sure you want to continue?", vbYesNoCancel)
If response = vbYes Then
findrecord = DMax("[Run_ID]", "tblsawperformance", "[Saw_ID = " &
strsaw)
strsql = "DELETE FROM tblsawperformance WHERE [Run_ID] = " &
findrecord
CurrentDb.Execute strsql
DoCmd.Close
DoCmd.SelectObject acForm, "switchboard", no
End If
If response = vbNo Then
Exit Sub
End If
If response = vbCancel Then
Exit Sub
End If
the vbno and vb cancel run perfectly but for some reason the vbyes will not
execute the findrecord and strsql code but if I move the docmd.close in front
of the findrecord it will run. Does anyone have any idea why my code will
not run properly
Any help would be much appreciated.
Thanks
Steve
Dim response As String
Dim findrecord As Integer
Dim strsaw As String
Dim strsql As Variant
strsaw = Saw_ID
response = MsgBox("If you continue closing this form, the saw
performance" & vbCrLf & _
"you were working on will be deleted from the database." &
vbCrLf & _
"Are you sure you want to continue?", vbYesNoCancel)
If response = vbYes Then
findrecord = DMax("[Run_ID]", "tblsawperformance", "[Saw_ID = " &
strsaw)
strsql = "DELETE FROM tblsawperformance WHERE [Run_ID] = " &
findrecord
CurrentDb.Execute strsql
DoCmd.Close
DoCmd.SelectObject acForm, "switchboard", no
End If
If response = vbNo Then
Exit Sub
End If
If response = vbCancel Then
Exit Sub
End If
the vbno and vb cancel run perfectly but for some reason the vbyes will not
execute the findrecord and strsql code but if I move the docmd.close in front
of the findrecord it will run. Does anyone have any idea why my code will
not run properly
Any help would be much appreciated.
Thanks
Steve