A2K format - BeforeUpdate Question

  • Thread starter Thread starter NoodNutt
  • Start date Start date
N

NoodNutt

G'day ppl

Have a form which after the user has completed all data input can invoice
job out.

I have a command button:

Private Sub InvoiceBtn_Click()
Dim InvoiceResp As Integer
InvoiceResp = MsgBox("Are you sure you want to mark this record for
Invoicing ?????", vbYesNo)
If InvoiceResp = vbYes Then
Me.Invoice = 1
Me.WeekNo = Me.DateDel
Else
DoCmd.CancelEvent
End If
End Sub

What I would like to have happen is that before it updates Me.Invoice, it
checks that the [PackStatus]=6 (6=Pack is Delivered).
So if the criteria doesn't match then display message prompt"Record cannot
be Invoiced, Not Delivered off system yet!".

TIA

Mark.
 
the CancelEvent action serves no purpose in your code. try

Private Sub InvoiceBtn_Click()

If Not Me!PackStatus = 6 Then
Msgbox "Record cannot be Invoiced, " _
& "Not Delivered off system yet!"
ElseIf MsgBox("Are you sure you want to " _
& "mark this record for Invoicing ?????", _
vbYesNo+vbDefaultButton2) = vbYes Then
Me!Invoice = 1
Me!WeekNo = Me!DateDel
End If

End Sub

hth
 
Back
Top