Table Validation Rules and Form Errors

G

Guest

First here's the problem that prompted the help:-
I've a table with a field lineamnt that is "required" and has a validation
rule >= 0.01. In my continuous sub form I use the Forms Error section to trap
error 3316 as follows:-
Case 3316
ans = MsgBox("Line amount is zero - Do you want this
allocation line removed?", vbYesNo)
Response = acDataErrContinue
If ans = vbYes Then
Me.Undo
DoCmd.GoToRecord , , acFirst
End If
Case Else
'Let access display it's default message
End Select
As you can see what I (well my users) want is to be able to automatically
remove the line if it's invalid. Using Undo almost works except when they
"blank" an amount on an already existing line. As far as I can tell you can't
use delete in the Forms Error section. So here's my questions:-
1. Any idea how to solve the immediate problem
2. Is there a nicer way to delete than
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
3. How can I make Access validation tidy. e.g. If it's mandatory data set
required in the table and trap in Form Error (which is what I was trying) or
perhaps always recalc before save (requery) - are they the same?

Thanks in anticipation for any particular help or general advice - John P.
 
G

Guest

Try putting coding in the before_Update event of the offending textbox, that
way you can *trap* the errors or evaluate it against your criteria at the
point of it being entered and replace a null or " " blank entry with a value
or msgbox prompt.

TonyT..
 

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