No Dupliacte - Indexed Field - Error Message

Anybody have a similiar problem?

  • YES! I also need to know how to do this!

    Votes: 1 25.0%
  • Yes, am working on something similiar.

    Votes: 0 0.0%
  • No, not working on anything related.

    Votes: 2 50.0%
  • NO! I know how to do this!

    Votes: 1 25.0%

  • Total voters
    4

Cosmos75

Registered User.
Local time
Today, 03:25
Joined
Apr 22, 2002
Messages
1,281
I have an indexed field (No Duplicates) that has a date value. The user uses the Calander Control 9.0 to choose the date. If that date already exists then the user can’t move forward or backward through the records until ECS is pressed to erase the entered duplicate. Is there a way to bypass the default ACCESS message of “You can’t go to specified record” to something that explains what is going on and what to do to?
 
You need to create error handling code that handles the duplicate index error. Generally, I place this on the "On Error" event of the form...


Private Sub Form_Error(DataErr As Integer, response As Integer)
On Error GoTo ErrorHandler

Select Case DataErr

Case 3022 'duplicate index

MsgBox "This date has already been used", vbOKOnly
me.yourdatefield.value = null
me.yourdatefield.setfocus
response = acDataErrContinue

Case else
'whatever code you want to put in to handle the error


End Select

ErrorHandlerExit:

Exit Sub

ErrorHandler:
MsgBox "Error No: " & Err.NUMBER & "; Description: " & Err.Description

Resume ErrorHandlerExit

end sub
 
Elana,

Thank you! :D

I will try this out and let you know!

THANKS!!!!
 

Users who are viewing this thread

Back
Top Bottom