Catch Error 3078 and use custom message (1 Viewer)

rainman89

I cant find the any key..
Local time
Today, 12:37
Joined
Feb 12, 2007
Messages
3,015
Hi all,
Im trying to catch this error to tell my users that they must fill in 2 combo boxes before they can proceed to the subform, but i dont know where to put it to catch it.
thought it would go in the before_update of the form, but i was still seeing the generic

Code:
"The microsoft Jet database engine cannot find a record in the table
ExpenseType with key matching field(s) expenseTypeID."

Here is what i have it in

Code:
Err_Form_BeforeUpdate:
    If Err = 3078 Then  
        MsgBox ("You must enter an expense type and payment method before assigning a case")
        Exit Sub
    Else
    
        Resume Exit_Form_BeforeUpdate
    End If
 

boblarson

Smeghead
Local time
Today, 09:37
Joined
Jan 12, 2001
Messages
32,059
Ray -

I think you should catch those in the form's before update event but with different code:
Code:
If IsNull(Me.ComboName) Then
  Msgbox "You need to fill in XXX before you can move to the subform", vbExclamation, "Data Error"
   Cancel = True
End If

If IsNull(Me.YourOtherComboName) Then
  Msgbox "You need to fill in ZZZ before you can move to the subform", vbExclamation, "Data Error"
   Cancel = True
End If
 

rainman89

I cant find the any key..
Local time
Today, 12:37
Joined
Feb 12, 2007
Messages
3,015
so catching that exact error wouldn't be practical?
 

boblarson

Smeghead
Local time
Today, 09:37
Joined
Jan 12, 2001
Messages
32,059
Oh, and you might change the message boxes so that if they don't want to continue you can undo things:

Code:
If IsNull(Me.ComboName) Then
    If Msgbox("You need to fill in XXX before you can move to the subform, do you want to continue?", vbQuestion + vbYesNo, "Data Error") = vbYes Then
      Cancel = True
   Else
     Cancel = True
     Me.Undo
End If

If IsNull(Me.YourOtherComboName) Then
   If Msgbox("You need to fill in ZZZ before you can move to the subform", vbQuestion + vbYesNo, "Data Error") = vbYes Then
     Cancel = True
  Else
     Cancel = True
     Me.Undo
End If
 

boblarson

Smeghead
Local time
Today, 09:37
Joined
Jan 12, 2001
Messages
32,059
so catching that exact error wouldn't be practical?

If the error persists then you might want to rethink it, but use something in the error handler similar. Just remember you have to use Cancel = True to cancel the update (even in your error handler).
 

rainman89

I cant find the any key..
Local time
Today, 12:37
Joined
Feb 12, 2007
Messages
3,015
If the error persists then you might want to rethink it, but use something in the error handler similar. Just remember you have to use Cancel = True to cancel the update (even in your error handler).

no that caught it. i had an error catch like that before, but it wasnt throwing. it was only going to the 3078. i wonder what i was missing.

thanks boB

btw pretty busy with the posts today... slow day at the office?
 

boblarson

Smeghead
Local time
Today, 09:37
Joined
Jan 12, 2001
Messages
32,059
btw pretty busy with the posts today... slow day at the office?
Sort of. My contract is running out and I am hardly able to work 4 hours a day on it. I'm working from home on it for the last several weeks and so I can just work on it when I feel like it. Right now, I don't feel like it. :D
 

rainman89

I cant find the any key..
Local time
Today, 12:37
Joined
Feb 12, 2007
Messages
3,015
Sort of. My contract is running out and I am hardly able to work 4 hours a day on it. I'm working from home on it for the last several weeks and so I can just work on it when I feel like it. Right now, I don't feel like it. :D

wow that was a short one!
 

boblarson

Smeghead
Local time
Today, 09:37
Joined
Jan 12, 2001
Messages
32,059
wow that was a short one!

Well, it could actually run a lot longer but the direction they are going is not the direction I want to go. In fact, there is a lot of bad programming, and design work, going on here and I just want to move on. I'm working on a few bug fixes and some documentation/help files, but I really want to get on to the next project. So, I'm looking right now.
 

Users who are viewing this thread

Top Bottom