If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Error handler help
Hello, I have a buttin on my form that takes me to the precious record. If I
go back to far it gives me a 2105 error. I Wanted to have a custom mesage and an ok button but I cant get it to work. It still opens the error window insted of a msg box. here is what I have Private Sub cmdPrevious_Click() On Error GoTo Err_MyErr DoCmd.GoToRecord , , acPrevious Exit_MyErr: Exit Sub Err_MyErr: If Err.Number 2105 Then MsgBox "Custom Test Message" End If Resume Exit_MyErr End Sub -- Thanks, Chad |
#2
|
|||
|
|||
Error handler help
Err_MyErr:
If Err.Number 2105 Then MsgBox "Custom Test Message" Resume Exit_MyErr Else Msgbox "Oops: you can't go any further!" Resume Next End If End Sub -- Doug Steele, Microsoft Access MVP http://www.AccessMVP.com/DJSteele (no e-mails, please!) "SoggyCashew" wrote in message ... Hello, I have a buttin on my form that takes me to the precious record. If I go back to far it gives me a 2105 error. I Wanted to have a custom mesage and an ok button but I cant get it to work. It still opens the error window insted of a msg box. here is what I have Private Sub cmdPrevious_Click() On Error GoTo Err_MyErr DoCmd.GoToRecord , , acPrevious Exit_MyErr: Exit Sub Err_MyErr: If Err.Number 2105 Then MsgBox "Custom Test Message" End If Resume Exit_MyErr End Sub -- Thanks, Chad |
#3
|
|||
|
|||
Error handler help
You should disable the PREV button when at the top, and the NEXT button when
at the bottom, so this can never occur. There are standard techniques for doing this, google them. -- Dorian "Give someone a fish and they eat for a day; teach someone to fish and they eat for a lifetime". "SoggyCashew" wrote: Hello, I have a buttin on my form that takes me to the precious record. If I go back to far it gives me a 2105 error. I Wanted to have a custom mesage and an ok button but I cant get it to work. It still opens the error window insted of a msg box. here is what I have Private Sub cmdPrevious_Click() On Error GoTo Err_MyErr DoCmd.GoToRecord , , acPrevious Exit_MyErr: Exit Sub Err_MyErr: If Err.Number 2105 Then MsgBox "Custom Test Message" End If Resume Exit_MyErr End Sub -- Thanks, Chad |
#4
|
|||
|
|||
Error handler help
Douglas, Im getting an error: label not defined? Also, Dorianthak I hae tried
to google your answer to my question but with no luck. Private Sub cmdPrevious_Click() On Error GoTo Err_MyErr DoCmd.GoToRecord , , acPrevious Err_MyErr: If Err.Number 2105 Then MsgBox "Custom Test Message" Resume Exit_MyErr Else MsgBox "Oops: you can't go any further!" Resume Next End If End Sub -- Thanks, Chad "Douglas J. Steele" wrote: Err_MyErr: If Err.Number 2105 Then MsgBox "Custom Test Message" Resume Exit_MyErr Else Msgbox "Oops: you can't go any further!" Resume Next End If End Sub -- Doug Steele, Microsoft Access MVP http://www.AccessMVP.com/DJSteele (no e-mails, please!) "SoggyCashew" wrote in message ... Hello, I have a buttin on my form that takes me to the precious record. If I go back to far it gives me a 2105 error. I Wanted to have a custom mesage and an ok button but I cant get it to work. It still opens the error window insted of a msg box. here is what I have Private Sub cmdPrevious_Click() On Error GoTo Err_MyErr DoCmd.GoToRecord , , acPrevious Exit_MyErr: Exit Sub Err_MyErr: If Err.Number 2105 Then MsgBox "Custom Test Message" End If Resume Exit_MyErr End Sub -- Thanks, Chad . |
#5
|
|||
|
|||
Error handler help
You forgot to include
Exit_MyErr: Exit Sub The entire thing should be Private Sub cmdPrevious_Click() On Error GoTo Err_MyErr DoCmd.GoToRecord , , acPrevious Exit_MyErr: Exit Sub Err_MyErr: If Err.Number 2105 Then MsgBox "Custom Test Message" Resume Exit_MyErr Else MsgBox "Oops: you can't go any further!" Resume Next End If End Sub -- Doug Steele, Microsoft Access MVP http://www.AccessMVP.com/DJSteele (no e-mails, please!) "SoggyCashew" wrote in message ... Douglas, Im getting an error: label not defined? Also, Dorianthak I hae tried to google your answer to my question but with no luck. Private Sub cmdPrevious_Click() On Error GoTo Err_MyErr DoCmd.GoToRecord , , acPrevious Err_MyErr: If Err.Number 2105 Then MsgBox "Custom Test Message" Resume Exit_MyErr Else MsgBox "Oops: you can't go any further!" Resume Next End If End Sub -- Thanks, Chad "Douglas J. Steele" wrote: Err_MyErr: If Err.Number 2105 Then MsgBox "Custom Test Message" Resume Exit_MyErr Else Msgbox "Oops: you can't go any further!" Resume Next End If End Sub -- Doug Steele, Microsoft Access MVP http://www.AccessMVP.com/DJSteele (no e-mails, please!) "SoggyCashew" wrote in message ... Hello, I have a buttin on my form that takes me to the precious record. If I go back to far it gives me a 2105 error. I Wanted to have a custom mesage and an ok button but I cant get it to work. It still opens the error window insted of a msg box. here is what I have Private Sub cmdPrevious_Click() On Error GoTo Err_MyErr DoCmd.GoToRecord , , acPrevious Exit_MyErr: Exit Sub Err_MyErr: If Err.Number 2105 Then MsgBox "Custom Test Message" End If Resume Exit_MyErr End Sub -- Thanks, Chad . |
Thread Tools | |
Display Modes | |
|
|