Evaluate Value after each step in process

  • Thread starter Thread starter BlakeD
  • Start date Start date
B

BlakeD

I have a code block that is effectively running some data validation
checks. I have them in the Form_BeforeUpdate event, and am running the
evalation from an outside module. Code looks like this:

Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Error_Form_BeforeUpdate
'Proceed with Data Checks until Exit or Cancel = True
Cancel = modDataChecks.CheckData(Me.ADDRESS, 1, "Address")
If True = Cancel Then Exit Sub
End If
Cancel = modDataChecks.CheckData(Me.FIRST_NAME, 1, "First
Name")
If True = Cancel Then Exit Sub
End If
Cancel = modDataChecks.CheckData(Me.LAST_NAME, 1, "Last Name")
If True = Cancel Then Exit Sub
End If

Exit_Form_BeforeUpdate:
Exit Sub

Error_Form_BeforeUpdate:
MsgBox Err.Description
Resume Exit_Form_BeforeUpdate
End Sub

How can I make access evaluate the value of Cancel after each step and
exit the sub if/when Cancel = True?
I have tried Do While/Loop, While/Wend, but they all evaluate at the
close of the loop / wend. Is there anything that evaluates after each
step?
 
try this:

'~~~~~~~~~~
Dim mBoo as boolean, i as integer
for i = 1 to 2 then
select case i
case 1
mBoo = modDataChecks.CheckData( _
Me.ADDRESS, 1, "Address")
case 2
mBoo = modDataChecks.CheckData( _
Me.FIRST_NAME, 1, "First Name")
end select
if mBoo then
CANCEL = true
exit sub
endif
next i
'~~~~~~~~~~~~~~`


Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 

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

Back
Top