No 3022 error using DoCmd and constant

A

Ann

To all:

I'm trying to save a record on an Access 2000 form using a
command button and the RunCommand with an intrinsic
constant,

DoCmd.RunCommand acCmdSaveRecord

but the database is not notifying the user of error 3022
(duplicate value in an indexed field) it just drops the
record. It will display error 3022 when the record is
saved manually any other way.

Does anyone have any ideas. Am I missing a library
(although the auto lists come up when I type in the
code),or is this a built in problem :) I havn't been able
to find anything else on the boards.

Any help would be greatly appreciated because I'm running
out of time.
Ann
 
A

Ann

Yes I've tried the Dirty property, and also Me.Refresh,
but I come up with the same problem.

I have had another suggestion of using a DLookup function
to search for a duplicate value, but domain aggregates can
be slow.

If you have any other suggestions I'd be happy to hear
them. Thanks.
-----Original Message-----
Hi,
Never used the RunCommand myself, have you tried
Me.Dirty = False
instead?

--
HTH
Dan Artuso, Access MVP


"Ann" <[email protected]> wrote in
message news:[email protected]...
 
A

Allen Browne

3022 is not a VBA error.
It can only be caught through the Error event of the form.
Check that event and see if you have anything there that could prevent the
error message from being shown.

Dan's idea of using the Dirty property is the safest way.
Me.Refresh will never notify you of a problem.

You may also want to check your VBA error trapping settings. From a Code
window, it's:
Tools | Options | General
 
A

Ann

Hi Allen:

I've checked the Error event and there was nothing there
at all, the proceedure hadn't even been created yet. So I
put a message box in the Error event to display any
arguments that were passed to it, and the event is not
being triggered by the Me.Dirty = False, it's only being
triggered by saving the record using the navigation
buttons or the records menu. When the event was triggered
my message box displayed the error code as 3022.

I also tried creating a command button to save the record
using the Tool Box Wizard and that doesn't trigger the
error either. The wizard's code is as follows:

On Error GoTo Err_Command21_Click

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70

Exit_Command21_Click:
Exit Sub

Err_Command21_Click:
MsgBox Err.Description
Resume Exit_Command21_Click

The Error Trapping was set to; Break on all Errors. I've
tried changing this setting to; Break on Unhandled
Errors, but that had not effect.

So I'm at a loss yet, I'm probably missing something
really obvious. Does anything else come to mind?

Thank you for your time.
Ann
 
D

Dan Artuso

Hi,
Here's what I tried:
Form bound to a table with an Indexed No Duplicates field.

Command button with:
Private Sub Command2_Click()
On Error GoTo cl_err
Me.Dirty = False
Exit Sub
cl_err:
MsgBox err.Number
End Sub

If I enter a duplicate number, I get the message box.
Try that simple test and see what happens
 
A

Ann

Hi Dan:

I'm still not getting the message using your code below.

The indexed No Duplicates field is not the key field and
it is not a required field, and the Allow Zero Length is
set to No; would those properties make any difference? I
wouldn't think so...

I know it sounds strange, but it is really behaving like
this. Could it be that some file in my Access software is
corrupted?

I don't know, I guess I'll keep casting around for the
solution. If you think of something else. . .

Thanks for your time.

Ann
-----Original Message-----
Hi,
Here's what I tried:
Form bound to a table with an Indexed No Duplicates field.

Command button with:
Private Sub Command2_Click()
On Error GoTo cl_err
Me.Dirty = False
Exit Sub
cl_err:
MsgBox err.Number
End Sub

If I enter a duplicate number, I get the message box.
Try that simple test and see what happens

--
HTH
Dan Artuso, Access MVP


"Ann" <[email protected]> wrote in
message news:[email protected]...
 
D

Dan Artuso

Hi Ann,
What I meant was to create a simple table and form for testing purposes.
See if it works with that, if it does, then you know it's something to with your
setup in the other form and table.
 

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