Errror handling for 2046 (Cant save records do to data missing/invalid etc..,)

R

Rob W

Greetings,

Have several forms where I have removed the navigation bar and use four
buttons to navigate and add records :-

Next Record
Previous Record
First Record
Last Record

I then have check on the previous and next records to ensure they wont try
to access records that dont exist i.e. records below 0 using code :-

Private Sub cmdPrevious_Click()
If [CurrentRecord] > 1 Then

Private Sub cmdNext_Click()

With Recordset
If .AbsolutePosition = .RecordCount - 1 Then
DoCmd.GoToRecord , , acNewRec
Else
DoCmd.RunCommand acCmdRecordsGoToNext

This method leaves itself open to problems when you have half filled in
forms or entered invalid data, rather than validate each field upon
entry/exit does anyone have an easy to use error handling code for 2046?

Thanks
Rob
 
R

Rob W

Add the familar 2105 to the error list too

Maybe something like this, but perhaps there are more sophisicated ways ! :-

on error goto MyErr
<code>
MyExit:
exit sub
MyErr:
if err.number<>2105 then
msgbox err.description
end if
resume MyExit
End Sub
 

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