Table validation warning not shown when attempting navigation

  • Thread starter Thread starter Fred Boer
  • Start date Start date
F

Fred Boer

I have two fields VolumeNumber and NumberofVolumes. I have created a
table-level validation rule (VolumeNumber<=NumberofVolumes). On my data edit
form, if I enter invalid data, and then attempt to save the changes using
the menu (Records>Save Record), a popup with my Validation text is shown.
However, if I simply attempt to navigate to another record, no Validation
text is displayed. The attempt to navigate to another record silently
fails....

Why doesn't the Validation text display? Do I have to do form-level
validation as well? I have no "Set warnings off/on" processes in my code..

Thanks!

Fred Boer
 
Oh, I forgot to add... If I create a new form using the wizard, then the
warning *does* display when I attempt to navigate to a new record. So it
must be something I've done, but I don't know what... :(

Thanks!


Fred
 
Discovered more info... If I use the Access's built-in form navigation bar,
the warning is displayed... If I use my custom navigation buttons, the
warning is not displayed...

Still befuddled...

Fred
 
Fred Boer said:
Discovered more info... If I use the Access's built-in form
navigation bar, the warning is displayed... If I use my custom
navigation buttons, the warning is not displayed...

Still befuddled...

Fred

So what's the code behind your navigation buttons? My first guess is
that you're ignoring errors somewhere.
 
Come on, Dirk! What kind of an idiot do you think I am!?... I mean, I'm not
that stup... oh, wait...

Ok, then... take your pick: blockhead, cretin, dimwit, donkey, dork, dumb
ox, dumbbell, dunce, dunderhead, fool, halfwit, ignoramus, imbecile,
nincompoop, ninny, nitwit, pinhead, pointy head, tomfool, twit, yo-yo....
<g>

Seriously, though, I did see that I was ignoring 2105, but I made the silly
assumption that the table validation error would have its own, different,
error number. *However*, I see that if I *do* remark out the 2105 trapping,
all the user sees is the "You can't go to the specified record." error
message; they *still* don't see the custom table validation error message.

Is there a way I can eat my cake and have it too? Ignore the 2105 error
message, but show the custom table validation error message? Or am I
continuing in my proud tradition of "clueless" thinking...?

As always, thanks so much!

Fred

Code behind "Next" command button, i.e. (OnClick: =fncGoNext)

Public Function fncGoNext()
On Error GoTo Err_fncGoNext
DoCmd.GoToRecord , , acNext
Exit_fncGoNext:
Exit Function
Err_fncGoNext:
If Err.Number <> 2105 Then
fncWRMSErrMsg Err.Number, Err.Description
End If
Resume Exit_fncGoNext
End Function

Code for fncWRMSErrMsg:

Public Function fncWRMSErrMsg(errNumber As Long, errDescription As String)
On Error GoTo Err_fncWRMSErrMsg

Dim Msg As String

Msg = "An error has occurred." & vbCr & vbCr & "Error Type: " & _
errDescription & vbCr & vbCr & "Error Number: " & errNumber & vbCr &
vbCr & _
"Please contact the Database Administrator immediately."
MsgBox Msg, , "W. Ross Macdonald School Library"

Exit_fncWRMSErrMsg:
Exit Function
Err_fncWRMSErrMsg:
MsgBox Err.Number, Err.Description
Resume Exit_fncWRMSErrMsg

End Function
 
Fred Boer said:
Come on, Dirk! What kind of an idiot do you think I am!?... I mean,
I'm not that stup... oh, wait...

Ok, then... take your pick: blockhead, cretin, dimwit, donkey, dork,
dumb ox, dumbbell, dunce, dunderhead, fool, halfwit, ignoramus,
imbecile, nincompoop, ninny, nitwit, pinhead, pointy head, tomfool,
twit, yo-yo.... <g>

Seriously, though, I did see that I was ignoring 2105, but I made the
silly assumption that the table validation error would have its own,
different, error number. *However*, I see that if I *do* remark out
the 2105 trapping, all the user sees is the "You can't go to the
specified record." error message; they *still* don't see the custom
table validation error message.

Is there a way I can eat my cake and have it too? Ignore the 2105
error message, but show the custom table validation error message? Or
am I continuing in my proud tradition of "clueless" thinking...?

As always, thanks so much!

Fred

Code behind "Next" command button, i.e. (OnClick: =fncGoNext)

Public Function fncGoNext()
On Error GoTo Err_fncGoNext
DoCmd.GoToRecord , , acNext
Exit_fncGoNext:
Exit Function
Err_fncGoNext:
If Err.Number <> 2105 Then
fncWRMSErrMsg Err.Number, Err.Description
End If
Resume Exit_fncGoNext
End Function


I'm not sure whether this will give you your custom validation message
or not, but it should give you a different error from 2105 at the very
least. Insert these lines immediately before the DoCmd.GoToRecord line:

If Me.Dirty Then
RunCommand acCmdSaveRecord
End If

Let me know what happens.
 
Dear Dirk:

Doing what you suggested solved the problem and brought up the custom
validation message appropriately. Thanks! There are a couple of small
wrinkles, however...

1. I use a public function, so I can't use "me.dirty"... Re-coding the
button to use a private procedure isn't a big deal, but just out of
curiosity, is there a way you *could* make a "me" type of reference work in
a public function? Something is nagging in my memory about this, but I
haven't time to look it up at the moment - I may have asked this question
before...

2. Also, I see now that the the err.number for the table validation is 3316,
so there might be some way to organize the error handling so that I might be
able to trap on that err.number and ignore the 2105 err.number..

However, I have to leave (1) and (2) for another day. Your suggestion is
simple, easy enough for me to understand, and I'll go with it for now. Now,
I've gotta go to the park with the kids... :)


Thanks so much! As always!

Fred
 
Fred Boer said:
Dear Dirk:

Doing what you suggested solved the problem and brought up the custom
validation message appropriately. Thanks! There are a couple of small
wrinkles, however...

1. I use a public function, so I can't use "me.dirty"... Re-coding the
button to use a private procedure isn't a big deal, but just out of
curiosity, is there a way you *could* make a "me" type of reference
work in a public function? Something is nagging in my memory about
this, but I haven't time to look it up at the moment - I may have
asked this question before...

Oh, right. I hadn't noticed that before. If this function will only
ever be called from a command button on a form -- which seems likely --
then you could use a reference to Screen.ActiveForm instead of Me:

Screen.ActiveForm.Dirty Then
RunCommand acCmdSaveRecord
End If
2. Also, I see now that the the err.number for the table validation
is 3316, so there might be some way to organize the error handling so
that I might be able to trap on that err.number and ignore the 2105
err.number..

It's possible, but this method seems easy enough.
However, I have to leave (1) and (2) for another day. Your
suggestion is simple, easy enough for me to understand, and I'll go
with it for now. Now, I've gotta go to the park with the kids... :)

And that's the best solution of all. Enjoy.
 
Back
Top