f



Custom error message for Runtime error 3022

I am trying trap Runtime error 3022 (duplicates) in the click event of
a command button that closes the form. I have code in the Form_Error
event that does a good job of providing a more meaningful error message
than the default. It works in every situation except when the user
clicks the close button.  I am using Me.Dirty=False to force a save but
if there are duplicates I just get the standard Runtime 3022 error
message.  I am wondering why the Form_Error event is not triggered.

Here are the two relevant subs:
First the Form_Error Sub...

Private Sub Form_Error(DataErr As Integer, Response As Integer)
Dim strMsg As String
Dim Group As String
Dim Selection As Integer
Const conDuplicateKey = 3022
Group = DLookup("[Name]", "tblGroups", "[GroupID] = " _
    & Me.GroupID)

If DataErr = conDuplicateKey Then
' Don't show built-in error messages
Response = acDataErrContinue
strMsg = "You have already entered hours for " & Group & vbCr
' Show a custom error message
MsgBox strMsg, vbOKOnly, "Duplicate Value"
    If Response = vbOK Then
    'Me.Undo
    cboGroupID.SetFocus
    End If
End If
End Sub

And the Close button's Click event

Private Sub cmdClose_Click()
    Me.Dirty = False
    DoCmd.Close acForm, Me.Name, acSaveYes


End Sub

I tried putting a On Error GoTo statement with a select case that
tested the Err.Number and then had similar code to Form_Error sub above
to produce a custom error message, but the standard error message was
being produced as soon as the Me.Dirty=False statement was reached. and
the On Error Go To ErrorHandler was ignored.  I obvously don't
understand the sequence of events enough.  Can anyone Help me out? By
the way, The Form allows entry of Volunteer Hours worked at a seniors
home by various church groups.

0
gactucker (5)
11/12/2006 12:05:49 AM
comp.databases.ms-access 42670 articles. 0 followers. Post Follow

8 Replies
1390 Views

Similar Articles

[PageSpeed] 43

Why not use the BeforeUpdate event of the form and/or the entry field for 
the primary key?  This would alert users to a duplicate before they continue 
to enter all the other info, rather than after the fact.  BTW, you can set 
the form's properties to remove the Close box.
-Ed



"g_man" <gactucker@gmail.com> wrote in message 
news:1163289949.814992.265000@f16g2000cwb.googlegroups.com...
>I am trying trap Runtime error 3022 (duplicates) in the click event of
> a command button that closes the form. I have code in the Form_Error
> event that does a good job of providing a more meaningful error message
> than the default. It works in every situation except when the user
> clicks the close button.  I am using Me.Dirty=False to force a save but
> if there are duplicates I just get the standard Runtime 3022 error
> message.  I am wondering why the Form_Error event is not triggered.
>
> Here are the two relevant subs:
> First the Form_Error Sub...
>
> Private Sub Form_Error(DataErr As Integer, Response As Integer)
> Dim strMsg As String
> Dim Group As String
> Dim Selection As Integer
> Const conDuplicateKey = 3022
> Group = DLookup("[Name]", "tblGroups", "[GroupID] = " _
>    & Me.GroupID)
>
> If DataErr = conDuplicateKey Then
> ' Don't show built-in error messages
> Response = acDataErrContinue
> strMsg = "You have already entered hours for " & Group & vbCr
> ' Show a custom error message
> MsgBox strMsg, vbOKOnly, "Duplicate Value"
>    If Response = vbOK Then
>    'Me.Undo
>    cboGroupID.SetFocus
>    End If
> End If
> End Sub
>
> And the Close button's Click event
>
> Private Sub cmdClose_Click()
>    Me.Dirty = False
>    DoCmd.Close acForm, Me.Name, acSaveYes
>
>
> End Sub
>
> I tried putting a On Error GoTo statement with a select case that
> tested the Err.Number and then had similar code to Form_Error sub above
> to produce a custom error message, but the standard error message was
> being produced as soon as the Me.Dirty=False statement was reached. and
> the On Error Go To ErrorHandler was ignored.  I obvously don't
> understand the sequence of events enough.  Can anyone Help me out? By
> the way, The Form allows entry of Volunteer Hours worked at a seniors
> home by various church groups.
> 


0
edrobichaud (274)
11/12/2006 4:19:28 AM
"g_man" <gactucker@gmail.com> wrote in message 
<1163289949.814992.265000@f16g2000cwb.googlegroups.com>:
> I am trying trap Runtime error 3022 (duplicates) in the click event 
> of a command button that closes the form. I have code in the 
> Form_Error event that does a good job of providing a more meaningful 
> error message than the default. It works in every situation except 
> when the user clicks the close button.  I am using Me.Dirty=False to 
> force a save but if there are duplicates I just get the standard 
> Runtime 3022 error message.  I am wondering why the Form_Error event 
> is not triggered.
>
> Here are the two relevant subs:
> First the Form_Error Sub...
>
> Private Sub Form_Error(DataErr As Integer, Response As Integer)
> Dim strMsg As String
> Dim Group As String
> Dim Selection As Integer
> Const conDuplicateKey = 3022
> Group = DLookup("[Name]", "tblGroups", "[GroupID] = " _
>     & Me.GroupID)
>
> If DataErr = conDuplicateKey Then
> ' Don't show built-in error messages
> Response = acDataErrContinue
> strMsg = "You have already entered hours for " & Group & vbCr
> ' Show a custom error message
> MsgBox strMsg, vbOKOnly, "Duplicate Value"
>     If Response = vbOK Then
>     'Me.Undo
>     cboGroupID.SetFocus
>     End If
> End If
> End Sub
>
> And the Close button's Click event
>
> Private Sub cmdClose_Click()
>     Me.Dirty = False
>     DoCmd.Close acForm, Me.Name, acSaveYes
>
>
> End Sub
>
> I tried putting a On Error GoTo statement with a select case that
> tested the Err.Number and then had similar code to Form_Error sub 
> above to produce a custom error message, but the standard error 
> message was being produced as soon as the Me.Dirty=False statement 
> was reached. and the On Error Go To ErrorHandler was ignored.  I 
> obvously don't understand the sequence of events enough.  Can anyone 
> Help me out? By the way, The Form allows entry of Volunteer Hours 
> worked at a seniors home by various church groups.

Try trapping it within your close button code - use resume next
for the part that might trigger an error, and check.

Private Sub cmdClose_Click()

    If Me.Dirty Then
        On Error Resume Next
        Me.Dirty = False
        If (Err.Number = 3022) Then
            Err.Clear
            Me.Undo
        End If
        On Error Goto 0 ' or use your error handler
    End If
    DoCmd.Close acForm, Me.Name, acSaveYes

End Sub

I don't think the Form Error triggers by runtime errors, which is
what you'll get when firing off the save through code.

-- 
Roy-Vidar


-1
11/12/2006 9:11:16 AM
  Roy, thanks for your reply, I tried your code, with a watch on
Err.Number.  The standard error message was triggered as soon as the
Me.Dirty=False statement was executed. Err.Number's value still had not
changed to 3022. Shouldn't execution skip to the next statement after
the line that triggers the error in other words to the
If(Err.Number....) statement?

RoyVidar wrote:
> "g_man" <gactucker@gmail.com> wrote in message
> <1163289949.814992.265000@f16g2000cwb.googlegroups.com>:
> > I am trying trap Runtime error 3022 (duplicates) in the click event
> > of a command button that closes the form. I have code in the
> > Form_Error event that does a good job of providing a more meaningful
> > error message than the default. It works in every situation except
> > when the user clicks the close button.  I am using Me.Dirty=False to
> > force a save but if there are duplicates I just get the standard
> > Runtime 3022 error message.  I am wondering why the Form_Error event
> > is not triggered.
> >
> > Here are the two relevant subs:
> > First the Form_Error Sub...
> >
> > Private Sub Form_Error(DataErr As Integer, Response As Integer)
> > Dim strMsg As String
> > Dim Group As String
> > Dim Selection As Integer
> > Const conDuplicateKey = 3022
> > Group = DLookup("[Name]", "tblGroups", "[GroupID] = " _
> >     & Me.GroupID)
> >
> > If DataErr = conDuplicateKey Then
> > ' Don't show built-in error messages
> > Response = acDataErrContinue
> > strMsg = "You have already entered hours for " & Group & vbCr
> > ' Show a custom error message
> > MsgBox strMsg, vbOKOnly, "Duplicate Value"
> >     If Response = vbOK Then
> >     'Me.Undo
> >     cboGroupID.SetFocus
> >     End If
> > End If
> > End Sub
> >
> > And the Close button's Click event
> >
> > Private Sub cmdClose_Click()
> >     Me.Dirty = False
> >     DoCmd.Close acForm, Me.Name, acSaveYes
> >
> >
> > End Sub
> >
> > I tried putting a On Error GoTo statement with a select case that
> > tested the Err.Number and then had similar code to Form_Error sub
> > above to produce a custom error message, but the standard error
> > message was being produced as soon as the Me.Dirty=False statement
> > was reached. and the On Error Go To ErrorHandler was ignored.  I
> > obvously don't understand the sequence of events enough.  Can anyone
> > Help me out? By the way, The Form allows entry of Volunteer Hours
> > worked at a seniors home by various church groups.
>
> Try trapping it within your close button code - use resume next
> for the part that might trigger an error, and check.
>
> Private Sub cmdClose_Click()
>
>     If Me.Dirty Then
>         On Error Resume Next
>         Me.Dirty = False
>         If (Err.Number = 3022) Then
>             Err.Clear
>             Me.Undo
>         End If
>         On Error Goto 0 ' or use your error handler
>     End If
>     DoCmd.Close acForm, Me.Name, acSaveYes
>
> End Sub
>
> I don't think the Form Error triggers by runtime errors, which is
> what you'll get when firing off the save through code.
> 
> -- 
> Roy-Vidar

0
gactucker (5)
11/13/2006 1:32:02 AM
Ed, thanks for your reply. Strangely enough, using the close box on the
form with duplicate records does trigger my custom error message. The
problem I found was when the last record added is a duplicate.  After
the combobox (cboGroupID) value is changed this changes the GroupID
field in the underlying table which is part of a multiple primary key
along with fields for the month and year. The Change event for this
combobox sets the focus in a text box to add the number of hours. If
the user enters hours in this box and then hits my close button and
hours have already been entered for this group in a previous record
then the standard Runtime error 3022 message is produced not my custom
message. If the user makes the duplicate entry and then tries to start
a new record, my message is displayed. It is only if it is the last
record before they hit my close button that the stock message gets
displayed. I have tried putting code into the before update event of
the form the combobox and numerous other events. Any ideas?

Ed Robichaud wrote:
> Why not use the BeforeUpdate event of the form and/or the entry field for
> the primary key?  This would alert users to a duplicate before they continue
> to enter all the other info, rather than after the fact.  BTW, you can set
> the form's properties to remove the Close box.
> -Ed
>
>
>
> "g_man" <gactucker@gmail.com> wrote in message
> news:1163289949.814992.265000@f16g2000cwb.googlegroups.com...
> >I am trying trap Runtime error 3022 (duplicates) in the click event of
> > a command button that closes the form. I have code in the Form_Error
> > event that does a good job of providing a more meaningful error message
> > than the default. It works in every situation except when the user
> > clicks the close button.  I am using Me.Dirty=False to force a save but
> > if there are duplicates I just get the standard Runtime 3022 error
> > message.  I am wondering why the Form_Error event is not triggered.
> >
> > Here are the two relevant subs:
> > First the Form_Error Sub...
> >
> > Private Sub Form_Error(DataErr As Integer, Response As Integer)
> > Dim strMsg As String
> > Dim Group As String
> > Dim Selection As Integer
> > Const conDuplicateKey = 3022
> > Group = DLookup("[Name]", "tblGroups", "[GroupID] = " _
> >    & Me.GroupID)
> >
> > If DataErr = conDuplicateKey Then
> > ' Don't show built-in error messages
> > Response = acDataErrContinue
> > strMsg = "You have already entered hours for " & Group & vbCr
> > ' Show a custom error message
> > MsgBox strMsg, vbOKOnly, "Duplicate Value"
> >    If Response = vbOK Then
> >    'Me.Undo
> >    cboGroupID.SetFocus
> >    End If
> > End If
> > End Sub
> >
> > And the Close button's Click event
> >
> > Private Sub cmdClose_Click()
> >    Me.Dirty = False
> >    DoCmd.Close acForm, Me.Name, acSaveYes
> >
> >
> > End Sub
> >
> > I tried putting a On Error GoTo statement with a select case that
> > tested the Err.Number and then had similar code to Form_Error sub above
> > to produce a custom error message, but the standard error message was
> > being produced as soon as the Me.Dirty=False statement was reached. and
> > the On Error Go To ErrorHandler was ignored.  I obvously don't
> > understand the sequence of events enough.  Can anyone Help me out? By
> > the way, The Form allows entry of Volunteer Hours worked at a seniors
> > home by various church groups.
> >

0
gactucker (5)
11/13/2006 1:46:16 AM
One common technique is to use the BeforeUpdate of the combobox to run a 
DLookup of the underlying table and check for any matching records, then 
either add it, or pop-up a msgbox and clear it.
-Ed

"g_man" <gactucker@gmail.com> wrote in message 
news:1163382376.113523.137250@b28g2000cwb.googlegroups.com...
> Ed, thanks for your reply. Strangely enough, using the close box on the
> form with duplicate records does trigger my custom error message. The
> problem I found was when the last record added is a duplicate.  After
> the combobox (cboGroupID) value is changed this changes the GroupID
> field in the underlying table which is part of a multiple primary key
> along with fields for the month and year. The Change event for this
> combobox sets the focus in a text box to add the number of hours. If
> the user enters hours in this box and then hits my close button and
> hours have already been entered for this group in a previous record
> then the standard Runtime error 3022 message is produced not my custom
> message. If the user makes the duplicate entry and then tries to start
> a new record, my message is displayed. It is only if it is the last
> record before they hit my close button that the stock message gets
> displayed. I have tried putting code into the before update event of
> the form the combobox and numerous other events. Any ideas?
>
> Ed Robichaud wrote:
>> Why not use the BeforeUpdate event of the form and/or the entry field for
>> the primary key?  This would alert users to a duplicate before they 
>> continue
>> to enter all the other info, rather than after the fact.  BTW, you can 
>> set
>> the form's properties to remove the Close box.
>> -Ed
>>
>>
>>
>> "g_man" <gactucker@gmail.com> wrote in message
>> news:1163289949.814992.265000@f16g2000cwb.googlegroups.com...
>> >I am trying trap Runtime error 3022 (duplicates) in the click event of
>> > a command button that closes the form. I have code in the Form_Error
>> > event that does a good job of providing a more meaningful error message
>> > than the default. It works in every situation except when the user
>> > clicks the close button.  I am using Me.Dirty=False to force a save but
>> > if there are duplicates I just get the standard Runtime 3022 error
>> > message.  I am wondering why the Form_Error event is not triggered.
>> >
>> > Here are the two relevant subs:
>> > First the Form_Error Sub...
>> >
>> > Private Sub Form_Error(DataErr As Integer, Response As Integer)
>> > Dim strMsg As String
>> > Dim Group As String
>> > Dim Selection As Integer
>> > Const conDuplicateKey = 3022
>> > Group = DLookup("[Name]", "tblGroups", "[GroupID] = " _
>> >    & Me.GroupID)
>> >
>> > If DataErr = conDuplicateKey Then
>> > ' Don't show built-in error messages
>> > Response = acDataErrContinue
>> > strMsg = "You have already entered hours for " & Group & vbCr
>> > ' Show a custom error message
>> > MsgBox strMsg, vbOKOnly, "Duplicate Value"
>> >    If Response = vbOK Then
>> >    'Me.Undo
>> >    cboGroupID.SetFocus
>> >    End If
>> > End If
>> > End Sub
>> >
>> > And the Close button's Click event
>> >
>> > Private Sub cmdClose_Click()
>> >    Me.Dirty = False
>> >    DoCmd.Close acForm, Me.Name, acSaveYes
>> >
>> >
>> > End Sub
>> >
>> > I tried putting a On Error GoTo statement with a select case that
>> > tested the Err.Number and then had similar code to Form_Error sub above
>> > to produce a custom error message, but the standard error message was
>> > being produced as soon as the Me.Dirty=False statement was reached. and
>> > the On Error Go To ErrorHandler was ignored.  I obvously don't
>> > understand the sequence of events enough.  Can anyone Help me out? By
>> > the way, The Form allows entry of Volunteer Hours worked at a seniors
>> > home by various church groups.
>> >
> 


0
edrobichaud (274)
11/13/2006 3:58:30 AM
"g_man" <gactucker@gmail.com> wrote in message 
<1163381522.766173.222950@i42g2000cwa.googlegroups.com>:
>   Roy, thanks for your reply, I tried your code, with a watch on
> Err.Number.  The standard error message was triggered as soon as the
> Me.Dirty=False statement was executed. Err.Number's value still had 
> not changed to 3022. Shouldn't execution skip to the next statement 
> after the line that triggers the error in other words to the
> If(Err.Number....) statement?
>
> RoyVidar wrote:
>> "g_man" <gactucker@gmail.com> wrote in message
>> <1163289949.814992.265000@f16g2000cwb.googlegroups.com>:
>>> I am trying trap Runtime error 3022 (duplicates) in the click event
>>> of a command button that closes the form. I have code in the
>>> Form_Error event that does a good job of providing a more 
>>> meaningful error message than the default. It works in every 
>>> situation except when the user clicks the close button.  I am using 
>>> Me.Dirty=False to force a save but if there are duplicates I just 
>>> get the standard Runtime 3022 error message.  I am wondering why 
>>> the Form_Error event is not triggered.
>>> 
>>> Here are the two relevant subs:
>>> First the Form_Error Sub...
>>> 
>>> Private Sub Form_Error(DataErr As Integer, Response As Integer)
>>> Dim strMsg As String
>>> Dim Group As String
>>> Dim Selection As Integer
>>> Const conDuplicateKey = 3022
>>> Group = DLookup("[Name]", "tblGroups", "[GroupID] = " _
>>>     & Me.GroupID)
>>> 
>>> If DataErr = conDuplicateKey Then
>>> ' Don't show built-in error messages
>>> Response = acDataErrContinue
>>> strMsg = "You have already entered hours for " & Group & vbCr
>>> ' Show a custom error message
>>> MsgBox strMsg, vbOKOnly, "Duplicate Value"
>>>     If Response = vbOK Then
>>>     'Me.Undo
>>>     cboGroupID.SetFocus
>>>     End If
>>> End If
>>> End Sub
>>> 
>>> And the Close button's Click event
>>> 
>>> Private Sub cmdClose_Click()
>>>     Me.Dirty = False
>>>     DoCmd.Close acForm, Me.Name, acSaveYes
>>> 
>>> 
>>> End Sub
>>> 
>>> I tried putting a On Error GoTo statement with a select case that
>>> tested the Err.Number and then had similar code to Form_Error sub
>>> above to produce a custom error message, but the standard error
>>> message was being produced as soon as the Me.Dirty=False statement
>>> was reached. and the On Error Go To ErrorHandler was ignored.  I
>>> obvously don't understand the sequence of events enough.  Can 
>>> anyone Help me out? By the way, The Form allows entry of Volunteer 
>>> Hours worked at a seniors home by various church groups.
>> 
>> Try trapping it within your close button code - use resume next
>> for the part that might trigger an error, and check.
>> 
>> Private Sub cmdClose_Click()
>> 
>>     If Me.Dirty Then
>>         On Error Resume Next
>>         Me.Dirty = False
>>         If (Err.Number = 3022) Then
>>             Err.Clear
>>             Me.Undo
>>         End If
>>         On Error Goto 0 ' or use your error handler
>>     End If
>>     DoCmd.Close acForm, Me.Name, acSaveYes
>> 
>> End Sub
>> 
>> I don't think the Form Error triggers by runtime errors, which is
>> what you'll get when firing off the save through code.
>> 
>> -- 
>> Roy-Vidar

If you are using resume next, then I think it should, could be you have
break on all errors (in VBE - Tools | Options - the General tab, set to
"Break on Unhandled Errors") - or is it another number? Something
triggered by for instance the before update event of the form?

-- 
Roy-Vidar


0
11/13/2006 7:51:59 PM
Roy,
I did have it set to "break on all errors". I didn't even think to look
at that.  Between your help and Ed's my problem is solved. I really
appreciate the help. Thanks so much


RoyVidar wrote:
> "g_man" <gactucker@gmail.com> wrote in message
> <1163381522.766173.222950@i42g2000cwa.googlegroups.com>:
> >   Roy, thanks for your reply, I tried your code, with a watch on
> > Err.Number.  The standard error message was triggered as soon as the
> > Me.Dirty=False statement was executed. Err.Number's value still had
> > not changed to 3022. Shouldn't execution skip to the next statement
> > after the line that triggers the error in other words to the
> > If(Err.Number....) statement?
> >
> > RoyVidar wrote:
> >> "g_man" <gactucker@gmail.com> wrote in message
> >> <1163289949.814992.265000@f16g2000cwb.googlegroups.com>:
> >>> I am trying trap Runtime error 3022 (duplicates) in the click event
> >>> of a command button that closes the form. I have code in the
> >>> Form_Error event that does a good job of providing a more
> >>> meaningful error message than the default. It works in every
> >>> situation except when the user clicks the close button.  I am using
> >>> Me.Dirty=False to force a save but if there are duplicates I just
> >>> get the standard Runtime 3022 error message.  I am wondering why
> >>> the Form_Error event is not triggered.
> >>>
> >>> Here are the two relevant subs:
> >>> First the Form_Error Sub...
> >>>
> >>> Private Sub Form_Error(DataErr As Integer, Response As Integer)
> >>> Dim strMsg As String
> >>> Dim Group As String
> >>> Dim Selection As Integer
> >>> Const conDuplicateKey = 3022
> >>> Group = DLookup("[Name]", "tblGroups", "[GroupID] = " _
> >>>     & Me.GroupID)
> >>>
> >>> If DataErr = conDuplicateKey Then
> >>> ' Don't show built-in error messages
> >>> Response = acDataErrContinue
> >>> strMsg = "You have already entered hours for " & Group & vbCr
> >>> ' Show a custom error message
> >>> MsgBox strMsg, vbOKOnly, "Duplicate Value"
> >>>     If Response = vbOK Then
> >>>     'Me.Undo
> >>>     cboGroupID.SetFocus
> >>>     End If
> >>> End If
> >>> End Sub
> >>>
> >>> And the Close button's Click event
> >>>
> >>> Private Sub cmdClose_Click()
> >>>     Me.Dirty = False
> >>>     DoCmd.Close acForm, Me.Name, acSaveYes
> >>>
> >>>
> >>> End Sub
> >>>
> >>> I tried putting a On Error GoTo statement with a select case that
> >>> tested the Err.Number and then had similar code to Form_Error sub
> >>> above to produce a custom error message, but the standard error
> >>> message was being produced as soon as the Me.Dirty=False statement
> >>> was reached. and the On Error Go To ErrorHandler was ignored.  I
> >>> obvously don't understand the sequence of events enough.  Can
> >>> anyone Help me out? By the way, The Form allows entry of Volunteer
> >>> Hours worked at a seniors home by various church groups.
> >>
> >> Try trapping it within your close button code - use resume next
> >> for the part that might trigger an error, and check.
> >>
> >> Private Sub cmdClose_Click()
> >>
> >>     If Me.Dirty Then
> >>         On Error Resume Next
> >>         Me.Dirty = False
> >>         If (Err.Number = 3022) Then
> >>             Err.Clear
> >>             Me.Undo
> >>         End If
> >>         On Error Goto 0 ' or use your error handler
> >>     End If
> >>     DoCmd.Close acForm, Me.Name, acSaveYes
> >>
> >> End Sub
> >>
> >> I don't think the Form Error triggers by runtime errors, which is
> >> what you'll get when firing off the save through code.
> >>
> >> --
> >> Roy-Vidar
>
> If you are using resume next, then I think it should, could be you have
> break on all errors (in VBE - Tools | Options - the General tab, set to
> "Break on Unhandled Errors") - or is it another number? Something
> triggered by for instance the before update event of the form?
> 
> -- 
> Roy-Vidar

0
gactucker (5)
11/13/2006 9:02:55 PM
Ed,

That did the trick. Between your help and Roy's my problem is solved. I
really appreciate both of you taking the time to help me out.

Ed Robichaud wrote:
> One common technique is to use the BeforeUpdate of the combobox to run a
> DLookup of the underlying table and check for any matching records, then
> either add it, or pop-up a msgbox and clear it.
> -Ed
>
> "g_man" <gactucker@gmail.com> wrote in message
> news:1163382376.113523.137250@b28g2000cwb.googlegroups.com...
> > Ed, thanks for your reply. Strangely enough, using the close box on the
> > form with duplicate records does trigger my custom error message. The
> > problem I found was when the last record added is a duplicate.  After
> > the combobox (cboGroupID) value is changed this changes the GroupID
> > field in the underlying table which is part of a multiple primary key
> > along with fields for the month and year. The Change event for this
> > combobox sets the focus in a text box to add the number of hours. If
> > the user enters hours in this box and then hits my close button and
> > hours have already been entered for this group in a previous record
> > then the standard Runtime error 3022 message is produced not my custom
> > message. If the user makes the duplicate entry and then tries to start
> > a new record, my message is displayed. It is only if it is the last
> > record before they hit my close button that the stock message gets
> > displayed. I have tried putting code into the before update event of
> > the form the combobox and numerous other events. Any ideas?
> >
> > Ed Robichaud wrote:
> >> Why not use the BeforeUpdate event of the form and/or the entry field for
> >> the primary key?  This would alert users to a duplicate before they
> >> continue
> >> to enter all the other info, rather than after the fact.  BTW, you can
> >> set
> >> the form's properties to remove the Close box.
> >> -Ed
> >>
> >>
> >>
> >> "g_man" <gactucker@gmail.com> wrote in message
> >> news:1163289949.814992.265000@f16g2000cwb.googlegroups.com...
> >> >I am trying trap Runtime error 3022 (duplicates) in the click event of
> >> > a command button that closes the form. I have code in the Form_Error
> >> > event that does a good job of providing a more meaningful error message
> >> > than the default. It works in every situation except when the user
> >> > clicks the close button.  I am using Me.Dirty=False to force a save but
> >> > if there are duplicates I just get the standard Runtime 3022 error
> >> > message.  I am wondering why the Form_Error event is not triggered.
> >> >
> >> > Here are the two relevant subs:
> >> > First the Form_Error Sub...
> >> >
> >> > Private Sub Form_Error(DataErr As Integer, Response As Integer)
> >> > Dim strMsg As String
> >> > Dim Group As String
> >> > Dim Selection As Integer
> >> > Const conDuplicateKey = 3022
> >> > Group = DLookup("[Name]", "tblGroups", "[GroupID] = " _
> >> >    & Me.GroupID)
> >> >
> >> > If DataErr = conDuplicateKey Then
> >> > ' Don't show built-in error messages
> >> > Response = acDataErrContinue
> >> > strMsg = "You have already entered hours for " & Group & vbCr
> >> > ' Show a custom error message
> >> > MsgBox strMsg, vbOKOnly, "Duplicate Value"
> >> >    If Response = vbOK Then
> >> >    'Me.Undo
> >> >    cboGroupID.SetFocus
> >> >    End If
> >> > End If
> >> > End Sub
> >> >
> >> > And the Close button's Click event
> >> >
> >> > Private Sub cmdClose_Click()
> >> >    Me.Dirty = False
> >> >    DoCmd.Close acForm, Me.Name, acSaveYes
> >> >
> >> >
> >> > End Sub
> >> >
> >> > I tried putting a On Error GoTo statement with a select case that
> >> > tested the Err.Number and then had similar code to Form_Error sub above
> >> > to produce a custom error message, but the standard error message was
> >> > being produced as soon as the Me.Dirty=False statement was reached. and
> >> > the On Error Go To ErrorHandler was ignored.  I obvously don't
> >> > understand the sequence of events enough.  Can anyone Help me out? By
> >> > the way, The Form allows entry of Volunteer Hours worked at a seniors
> >> > home by various church groups.
> >> >
> >

0
gactucker (5)
11/13/2006 9:07:49 PM
Reply:

Similar Artilces:

MS Access 2.0 "reserved error -1302 There is no message for this error"
Hi, Folks! I am trying to resurrect a copy of MS Access 2.0 (MS Office 4.3) under WFW v3.11. I cannot start up Access because of a couple of error messages (paraphrased): 1. Opening Access: "Cannot open SYSTEM.MDA, file exclusively locked" 2. When I try to join SYSTEM.MDA in Workgroup Administrator it goes through okay but Access comes up with the same error message. 3. When trying to create a new SYSTEM.MDA file in Workgroup Administrator: "Reserved Error (-1302)..." What the Fudge!?! Does anyone know what's going on? Does anyone know how it can be fixed? A...

Intercepting error Access error messages
Is it possible to intercept an error message, generated by Access, and replace it with your own warning. For example entering a duplicate entry for a key field? Thanks Geoff Use the Before Update event of the control in the form to check for duplicate. Set Cancel = true, undo the edit and output a message if there is an error. There are example in Access help under beforeupdate. "Geoff" <gfriar@freenetname.co.uk> wrote in message news:PaKdnTzR1uc84HXYRVnyuAA@brightview.com... > Is it possible to intercept an error message, generated by Access, and > replace it with your own warning. For example entering a duplicate entry > for a key field? > > > > Thanks > > Geoff > > Check out the Form_OnError event. -Tom. Well, you can definitely write VBA code to intercept Access errors and do your own thing in response to them instead of, or in addition to, whatever Access was going to do. So sure, you could display your own message instead of Access'. In addition -- I've never done this, but I'm pretty sure I've read about it -- you can register your own error numbers and error descriptions. So I suppose once you've done that, you can intercept Access' error and Raise your own. But I repeat, I've never done it so I don't know what the problems might be. --- Bob Bridges, rhbridg@attglobal.net, cell 336 382-7313 (hotel) 612 869-7704 xt 118, fax 612 869-7383 /* A crooked politici...

(assert-error) tests errors and error messages
I wrote (assert-error) to make sure that a function generates an error, and verify the error message. What do you think? Below is the definition and a few test cases, for Emacs 22.1.50. (require 'cl) (defmacro assert-error (form &optional regexp) "FORM must signal an error. Signal an error otherwise. Additionally, the error message must match REGEXP. Case is ignored while matching REGEXP." (let ((msg (make-symbol "msg")) (ok (make-symbol "ok")) (res (make-symbol "res"))) `(let ((,ok nil)) (condition-case err ;; Evaluate FORM and save the result. (set ',res ,form) (error ;; This runs when FORM signals an error of any kind. (set ',ok t) (set ',msg (error-message-string err)))) (unless ,ok (error "Did not signal an error: %s (returned %s)" ',form ,res)) (when ,regexp ;; Here we know that FORM signaled an error, and that the ;; caller wants to check the error message. (unless (let ((case-fold-search t)) (string-match ,regexp ,msg)) (error "Error message does not match \"%s\": \"%s\"" ,regexp ,msg)))))) ;; Test assert-error, mostly by running it against itself. (assert-error (assert-error nil) "did not signal.*nil") (assert-error (assert-error t) "\\bt\\b") (as...

Custom error handler suppress error messages
While using a custom error handler I noticed that the suppressing errors (a warning, in this case) does not work. I am using exif_read_data and want to suppress a warning message I might get by prepending '@' (exif_read_data has a problem with a particular exif format and issues a warning, [exif_read_data]: corrupt EXIF header: maximum directory nesting level reached, ... even though it returns the data I want). If I am using my own error handler the warning comes through, but if I do not include my error handler (and use the built-in Php error handler), the warning...

Error Message Help "Error Accessing File"
Hello, I don't understand this error message." Error accessing File. Network Connection may have been lost." I'm not using any network connection for the database. In the VBA editor is goes to "Private Sub Form_DblClick(Cancel As Integer)". I have been making a bunch of changes and I'm sure I have done something to corrupt this mdb but I don't know where to start of this one. I hope there is help for me... Thanks Norris x-- 100 Proof News - http://www.100ProofNews.com x-- 3,500+ Binary NewsGroups, and over 90,000 other groups x-- Access to o...

When is an error not an error?
When it's OSS slopware, of course. http://www.angelfire.com/planet/dfs0/Knode_send_error.png On 2006-09-12 02:42, * DFS wrote: > When it's OSS slopware, of course. > > http://www.angelfire.com/planet/dfs0/Knode_send_error.png > Well, some time ago I had a problem with OE - too long reference line to other posts, and OE of course refused to send... then crashed. Should I name it a feature? -- Andrea On Tue, 12 Sep 2006 03:25:29 +0200, Andrea wrote: > On 2006-09-12 02:42, * DFS wrote: >> When it's OSS slopware, of course. >> >> http:/...

When is an error not an error?
The Java language specification claims in: 8.8.7.1 Explicit Constructor Invocations .... "If an anonymous class instance creation expression appears within an explicit constructor invocation statement, then the anonymous class may not refer to any of the enclosing instances of the class whose constructor is being invoked." Helpfully it gives an example: "For example: class Top { int x; class Dummy { Dummy(Object o) {} } class Inside extends Dummy { Inside() { super(new Object() { int r = x; }); // error } Inside(final int y) { super(new Object() { int r = y; }); // correct } } } " Notice the word 'error' in the comment. This example compiles without error and produces the correct code. In what sense is it an 'error'? It is not a compiler error, it is not a runtime error. To quote Douglas Adams "this must be some new meaning of the word 'error' with which I am unfamiliar". Any idea what's gone wrong? In article <gepkhr$rop$1$8302bc10@news.demon.co.uk>, Anon <blackhole@nowhere.com> wrote: > The Java language specification claims in: > 8.8.7.1 Explicit Constructor Invocations [<http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.8. 7.1>] > Notice the word 'error' in the comment. This example compiles without > error and ...

Error Message: "Error accessing product object method"
We get the Error message "Error accessing product object method" when we execute the following Lotus Script instruction: Call outlineTW.Save() in an agent. Our developer uses the Notes 5 Designer and those who have problems use the Notes 6 clients. Could it be the cause of the prolem? Or else: any help please? Hi Lucky Luke, > We get the Error message "Error accessing product object method" when > we execute the following Lotus Script instruction: Call > outlineTW.Save() in an agent. What type of object is outlineTW? I'm writing a script lib...

Error Writing to MS Access Database with Replication
Greetings, I have a Microsoft Access database that is replicated accross several computers using the built-in Access replication technology. Access replication supports automatically synchronizing updates that have been applied separately to each copy of the database. When replication is enabled in MS Access, a number of "system" columns are added to every table in the database in order to facilitate the synchronization database. Note that these columns are not visible by default within MS Access. I would like to insert new rows into one of the tables in this database using PROC SQL. The statements that I am using to perform this function worked fine before replication was enabled on the database. After replication was enabled, I now receive an error which indicates that SAS is attempting to modify the contents of the replication system columns. SAS should NOT be doing this, as the contents of these columns are automatically maintained by MS Access, and are protected against modification by external applications. The code that I am using, and the error message that I receive are provided below. Can anyone advise of a simple solution to this problem? Perhaps some other option to the libname statement or connect string that I have overlooked...? Thanks, s/KAM 508 %let MJFile=\\Speedy\D\Program Files\MJ Systems \LogSleuth2\Database\LogSleuth.mdb; <snip> 525 libname MJ ODBC noprompt="uid=admin;pwd=&MJPW;dsn=MS Access Database;DBQ=&MJ...

Error returned with no error message
Hi All, I am trying to access a Transform Data Task in a DTS by double clicking it. When I do, I get a message similar to "HResult of 0x80004005 (-2147467259) returned Unexpected error occurred. An error was returned without an error message" and the properties screen does not appear. Firstly this has got to be the most useless alert ever to appear on my screen, but more importantly what can I do about it? I cannot execute the step either as I get the same message. I thought that the DTS may have become corrupted but it is also happening when I create new DTS packages. Can...

Error: AgentSocketPullInput error message
Hello all... I'm getting the following message repeated in the /var/adm/snmpd.log on HP-UX 11.11 server: AgentSocketPullInput: short read pending on socket close, data discarded at line 491 in file ../common.c I've been surfing around for the info but haven't had any luck finding a reference to this error message and what it might mean? I've done a stare 'n compare against a working snmpd.conf that's working just fine. Would anybody have a cluegram as to where I can look for some idea what this message is telling me...? ...

Error message: 'error accessing file network connections may have been lost'
After working up an Access2000 database in Windows XP Pro over two months I am quite suddenly getting an error when attempting to open up forms. The error reads 'error accessing file network connections may have been lost' I would be most grateful for help as I until I solve this one I will not be confident opening up other databases on my machine which still seem to be working properly and I need to get on with finishing the errant application (Just in case it is relevant I installed Office XP with Access 2002 a week ago but this database has not been opened up on it. It may be a c...

Exception error at during runtime when trying to update Access Database
I am using the OleDbDataAdapter object linked to a Microsoft Access database and during runtime when the code attepmts to update the adapter with the code: oleMovieLibAdapter.Fill(dsMovieLib, "movielibrary") I get the following error: An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll Here is all of my code for the add movie button: 'declare variables Dim Movie_Row As DataRow 'Create new row in table Movie_Row = dsMovieLib.Tables("movielibrary").NewRow '...

MS Jet database engine error message
In Access'97, I am currently trying to run a Select query, which I normally run every week, without problem, until now. I am currently getting the following error message; The Microsoft Jet database engine stopped the process because you and another user are attempting to change the same data at the same time I'm not trying to change anything, nor do I believe that anyone else is, or should be in my database. Does anyone now what this means and how I can resolve it and continue with my normal process? Any help is much appreciated! Thanks Delete the LDB file when there's no-one using the MDB file (including you). Thanks for this, but unfortunately, there's no *.ldb file (have shown hidden file types etc). I'm currently running my SQ again, taking each tbl & qry out one at a time to see if I can pin-point the error. However, when viewing each tbl behind my SQ individual they're ok, as are the SQ's (there's two sub within the main one) when I run them seperately. Any more suggestions? Many thanks. ...

access 97: option group and runtime error message 13
hi, i have this form with the option filter. for some reason, whenever the user chooses OptCreateFilter = 3, they receive an error message "type mismatch 13." i looked at the data type of all three variables ([Created], [AutoCreated], [CreatedMoved]) and they are all YES/NO data types. then i made a sql workaround from the query to filter out both [Created] and [AutoCreated] fields. of course it did not work. what am i doing wrong here? thanks in advance, jung Private Sub OptCreateFilter_AfterUpdate() If Me![OptCreateFilter] = 1 Then Me.Filter = "" Me.F...

"Oracle error occurred, but error message could not be retrieved from Oracle" error when restarting application
Hi, we're using Oracle 10g, in combination with Delphi (7). Application uses Oracle client dll (oraociei10.dll). Quick explenation about the structure (All files are on the network): - A launcher application is started by the client. The launcher application checks an .ini file for the current application versie (.exe filename with a version postfix, e.g. "Application_112.exe"). The launcher starts the executable specified in the .ini file. In this way we can "release" by putting a new .exe file and updating the .ini file. The problem: In our application we've got the functionality to restart the application when a new version is available. If the application detects there is a new version (by checking the .ini file) the user can restart the application. The next thing happens on a restart: - Application starts the launcher again, the handle of the application is passed. - Application closes itself - Launcher waits until the application handle is gone - Launcher restarts application again (new version). When starting the application again, oracle generated the beautiful: "Oracle error occurred, but error message could not be retrieved from Oracle" message. Initial thought was that the Oracle client was not unloaded, so we made the launcher wait up to 60 seconds after the application was closed and before the application is started again. But even then the error occurs. Detail: When not using the oracle client , but the "n...

E2900 error on boot: TL = 1, TT = 32. ERROR: Data Access Error -- Help??
Can someone help decipher this error below? Had Sun CE install 32Gb memory into 2 system boards (64Gb total), and now we are getting this error. We tried powering it back up with each system board individually, and get same error no matter which board is in, or both. So we're pretty sure it's not a single dimm that is the problem Sun Fire E2900 OpenFirmware version 5.19.4 (01/19/06 18:06) Copyright 2006 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. SmartFirmware, Copyright (C) 1996-2001. All rights reserved. 32768 MB memory installed, TL = 1, TT = 32....

Automation Error Unspecified Error Message
I'm running a query and get the error in the subject line above. This is the query: strSQL = "SELECT XL_Import.Gate, XL_Import.Region, XL_Import.Section, XL_Import.[Charter Fields], " & _ "XL_Import.[Data Value], XL_Import.[Matrix 1 Table], XL_Import.[Matrix 1 Attribute] " & _ "FROM XL_Import " & _ "WHERE (XL_Import.Section = 'DF" & x & "') AND (XL_Import. [Data Value]<>'0') AND " & _ "(XL_Import.[Matrix 1 Table]= 'ProductOption') AND (XL_Import. [Matrix 1 Attribute] ='package direction');" If I paste this into an accesss query it runs fine. Any ideas what is going on? I'm using Access 2003. Greetings, I simplified your query by removing parens and the preceding table name for each field: strSQL = _ "SELECT Gate, Region, Section, [Charter Fields], " & _ "[Data Value], [Matrix 1 Table], [Matrix 1 Attribute] " & _ "FROM XL_Import " & _ "WHERE Section Like 'DF*' AND [Data Value]<>'0' AND " & _ "[Matrix 1 Table]= 'ProductOption' AND [Matrix 1 Attribute] ='package direction'" I also combined your X variable with a Like and * -- WHERE Section Like 'DF*' AND... What I would do if I were you, starters, is to remove the Where clause and select like the top 1 SELECT Top 1 Gate, Region, Section, [...

Reserved Error (-7711); there is no message for this error
I am trying to pick out data from an OBDC Source so i have created a link table to it. I have created a query to look at the data in this table. I have chosen all the fields that i require. There is a date field in there which looks at sets of data for a week. If i go into the query design and actually type in the criteria of the date in this format it works year-month-day (2004-02-09). So i have tried to put a text box in to be able to type the date in and be able to search for. This doesnt work. This is the SQL i am using. Its really basic yet cant see the problem! SELECT CTCH_WK.CELLID, ...

EvaluateFunction error .... fails with no error message
When I attempt to make a call to a a function in a matlab assembly built for .net, an exception is thrown with error message (with no message!): .... MWMCR::EvaluateFunction error ... .. StackTrace: at MathWorks.MATLAB.NET.Utility.MWMCR.EvaluateFunction(String functionName, Int32 numArgsOut, Int32 numArgsIn, MWArray[] argsIn) at MathWorks.MATLAB.NET.Utility.MWMCR.EvaluateFunction(Int32 numArgsOut, String functionName, MWArray[] argsIn) at RevScenarios.RevScenarios.generateScenarios(Int32 numArgsOut, MWArray NetRevenue, MWArray AdSpend, MWArray ClicksCharged, MWArray AvgPosition, MWArray NumScenarios) The error I believe has something to do with the MWArray assembly. This error only occurs when using the 64bit version of MWArray.dll. Using a 32bit version of the assembly works just fine. Both MCR v710 32bit and 64bit ARE installed on the machine when it's running. What could be causing this? ...

Error 680
Hello My PC runs Windows XP Pro and i need to bypass the pop-up error message '680' (no dial tone) This computer is a self-running station, totally automatic. When Windows displays this message, the computer waits for an human activity: clic on the button to confirm that I have seen the message. I can't accept it because this error message blocks my automatic processes. What can I do to bypass it ? I would like not to display this kind of pop-up message and keep the system running automatically, or validate it automatically (so, the computer can keep on running its processes)...

Mapping error codes to error messages
I need to make an error handling framework to be used by C++ applications running on HP-UX. In this, the application error codes can be mapped to pre-defined error messages. The framework would have C++ exception classes for error information propagation. I however have no clue on how to map the error codes to the messages, and efficiently access the messages through a simple mapping class or function. I know this is not exactly a UNIX question that we are discussing, but is anybody aware of any implementation techniques. Should it necessarily be a static array indexed by error codes or some r...

Reserved error (-1524); there is no message for this error.
I am trying to run a pretty simple select query in Access 2007, and I keep getting the error message "Reserved error (-1524); there is no message for this error." There are no linked tables in the database - the design of the database is very simple. I should also note that I ran the "compact and repair database" tool and I am still getting the same error message. Any thoughts? Thanks! "adampierce" <apmessner@gmail.com> wrote in message news:f89f4544-0e1e-4140-9b69-4fac8656ae5d@l1g2000hsa.googlegroups.com... >I am trying to run a pretty simple select query in Access 2007, and I > keep getting the error message "Reserved error (-1524); there is no > message for this error." There are no linked tables in the database - > the design of the database is very simple. > > I should also note that I ran the "compact and repair database" tool > and I am still getting the same error message. > > Any thoughts? > > Thanks! Just a guess..... Do you have any field names that use "reserved" words? Like: Date, Name, Min, Max, Sum, Where, etc Would you post the query? Fred Zuckerman I don't think I'm using any reserved words...Here is the SQL: SELECT E_CURRENT_DATA.Prefix, E_CURRENT_DATA.LastName, E_CURRENT_DATA.FirstName, E_CURRENT_DATA.Address, E_CURRENT_DATA.City, E_CURRENT_DATA.ZIP FROM E_CURRENT_DATA WHERE (((E_CURRENT_DATA.Volunteer)=False) AND ((E_CURRENT_DATA.Absent)=Fa...

ERROR() : Multi-line error messages
Hi all. I am working with this program where I scan lots of text strings and check their formats. If an error is found, the program terminates while printing an error message to screen as error(ErrorText); One of the strings is required to be on the letter/digit format ABC123 I have seen that there is a risk that the users either hit the wrong keys (hits 'O' instead of '0') or read the alphanumeric codes wrong ('l' instead of '1') when they enter them, so I want to be able to check the entered codes and display an error message like "Error in parameter SomeCode. Expects format 'ABC123'. Found letter 'l' (lowercase 'L') in digit position 1" The text in my own code is a little bit more elaborate, it prints the code that was actually found and goes into some details about where the error might have originated etc. These sorts of error messages quickly become too long to fit comfortably into one line in the command window. How can I break the error message up to appear over several lines when I use the function ERROR? Rune "Rune Allnor" <allnor@tele.ntnu.no> writes: > I am working with this program where I scan lots of > text strings and check their formats. If an error > is found, the program terminates while printing > an error message to screen as > > error(ErrorText); > [...] > These sorts of error messages quickly become > too long to fit comfortably i...

Web resources about - Custom error message for Runtime error 3022 - comp.databases.ms-access

Message - Wikipedia, the free encyclopedia
A message is a discrete unit of communication intended by the source for consumption by some recipient or group of recipients. A message may ...

How a Perth SAS soldier’s spiritual message from beyond the grave changed lives
SOMETHING was telling Charlotte she had to go. She didn’t want to. She never left her cousin’s farm in the northwest of NSW before enjoying a ...

How a Perth SAS soldier’s spiritual message from beyond the grave changed lives - PerthNow Search Search ...
SOMETHING was telling Charlotte she had to go. She didn’t want to. She never left her cousin’s farm in the northwest of NSW before enjoying a ...

Apple releases OS X 10.11.4 beta 7 with Messages & Notes improvements, more
In addition to releasing the seventh beta of iOS 9.3 yesterday, Apple today has released OS X 10.11.4 beta 7 to developers and public beta testers. ...

WhatsApp testing text formatting to include bold and italics in messages
The latest beta release of WhatsApp features some basic text formatting options including bold and italics. While features in beta versions of ...

The Fed's Hidden Message
Officials are strangely OK with low inflation. The U.S. Federal Reserve's latest economic projections contain an encoded message crucial to understanding ...

The world's oldest message in a bottle spent 108 years at sea for a critical science experiment
The world's oldest message in a bottle was actually one of more than 1,000 identical bottles that helped shape our understanding of ocean currents. ...

WATCH: Tom Izzo’s Emotional Message To Denzel Valentine After Michigan State’s Shocking Loss
"We just got beat," Izzo managed to croak out after a 90-81 loss to No. 15 seed Middle Tennessee State on Friday ended their pursuit far sooner ...

Foxx parlays personal story, message of change to big win
Chicago Tribune Foxx parlays personal story, message of change to big win Chicago Tribune Cook County State's Attorney Anita Alvarez and challengers ...

What’s Taking So Long With that Email? Google Adds Smart Reply To Messages
Not sure how to reply to that email about your upcoming class reunion from Karen? Don’t worry your pretty little head, Google has apparently ...

Resources last updated: 3/21/2016 1:22:04 AM