can't get the cancil to work in statment.

J

jon

Hi
I can not get a cancel to work I have try a few variations but it still wont
work.

I have pasted the code below.
Any help is welcome.

thanks

Jon


Private Sub ButUpdate_Click()
On Error GoTo Err_ButUpdate_Click

Dim db As DATABASE
Dim rst As Recordset
Dim blnok As Boolean


If Me![CmbFreeStsteStatus] = 2 Then
Me![ChkFreeststateDone] = -1
Set db = CurrentDb()
Set rst = db.OpenRecordset("ComponentNos", dbOpenTable)

With rst
rst.Index = "Componet No"
rst.Seek "=", [CmbJob]
.Edit
.Fields("FreeStateCount") = .Fields("FreeStateCount") + 1
.Fields("FreeStatePassCount") = .Fields("FreeStatePassCount") +
1
.Update

End With

ElseIf Me![CmbFreeStsteStatus] = 3 Then ' job requires free stating
If Me![FreeStatePassFail] = 0 Then

blnok = confirm(" Are You sure the Job has Failed?")
If blnok = True Then
DisplayMessage ("oh shit")
Me![CmbFreeStsteStatus] = 4
Me![ChkFreeststateDone] = -1
Set db = CurrentDb()
Set rst = db.OpenRecordset("ComponentNos", dbOpenTable)

With rst
rst.Index = "Componet No"
rst.Seek "=", [CmbJob]
.Edit
.Fields("FreeStateCount") = 0
.Fields("FreeStatePassCount") = 0
.Update

End With
Else
.Cancel '***** error here
End If
End If

End If

DoCmd.Close

Exit_ButUpdate_Click:
Exit Sub

Err_ButUpdate_Click:
MsgBox Err.Description
Resume Exit_ButUpdate_Click

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top