A
AlCamp
I need to better understand how the Cancel method works.
I have the following code that works well... (thanks Jonathan Parminter)
When the user enters a SpoolQty amount that causes the NetWeight calculation
to go Negative (< Zero) the user is msgbox warned, the illigitimate value
they entered reverts back to the original value, and the cursor stays in the
SpoolQty field to allow a legitimate value to be entered. (Several fields
use this same Function)
Field [SpoolQty] events...
BeforeUpdate [EventProcedure]
AfterUpdate =CheckNetWeight([SpoolQty])
Private Sub SpoolQty_BeforeUpdate(Cancel As Integer)
Cancel = CheckNetWeight([SpoolQty])
End Sub
Public Function CheckNetWeight(CallingCtl As Control) As Boolean
Dim fCancel As Boolean
If NetWeight <= 0 Then
' MsgBox stuff here.....
Response = MsgBox(Prompt, vbOKOnly + vbCritical, Title)
If Response = vbOK Then
fCancel = True
CallingCtl.Undo
End If
End If
CheckNetWeight = fCancel
End Function
Could someone tell me how this works? I just need a brief "synopsis",
such as... what the BeforeUpdate code means, how a BeforeUpdate event can
Cancel a function run by the AfterUpdate event, and what designating a
function "as Boolean" means.
Also, is this the best method/events to be using?
Any help would be appreciated... Can't relate this code to what I've
learned about Cancel in Help. I'm missing a concept here, and looking for
an "epiphany."
Thanks in advance,
Al Camp
I have the following code that works well... (thanks Jonathan Parminter)
When the user enters a SpoolQty amount that causes the NetWeight calculation
to go Negative (< Zero) the user is msgbox warned, the illigitimate value
they entered reverts back to the original value, and the cursor stays in the
SpoolQty field to allow a legitimate value to be entered. (Several fields
use this same Function)
Field [SpoolQty] events...
BeforeUpdate [EventProcedure]
AfterUpdate =CheckNetWeight([SpoolQty])
Private Sub SpoolQty_BeforeUpdate(Cancel As Integer)
Cancel = CheckNetWeight([SpoolQty])
End Sub
Public Function CheckNetWeight(CallingCtl As Control) As Boolean
Dim fCancel As Boolean
If NetWeight <= 0 Then
' MsgBox stuff here.....
Response = MsgBox(Prompt, vbOKOnly + vbCritical, Title)
If Response = vbOK Then
fCancel = True
CallingCtl.Undo
End If
End If
CheckNetWeight = fCancel
End Function
Could someone tell me how this works? I just need a brief "synopsis",
such as... what the BeforeUpdate code means, how a BeforeUpdate event can
Cancel a function run by the AfterUpdate event, and what designating a
function "as Boolean" means.
Also, is this the best method/events to be using?
Any help would be appreciated... Can't relate this code to what I've
learned about Cancel in Help. I'm missing a concept here, and looking for
an "epiphany."
Thanks in advance,
Al Camp