By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,099 Members | 2,156 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,099 IT Pros & Developers. It's quick & easy.

Can't suppress warnings!

P: n/a
Hi,

I have this Access 2003 DB that handles Clients and their respective
items of correspondence in a one to many relationship. Clients details
are entered in frmPerson. When it comes to recording an item of
correspondence this is done via another form/subform ( main form is
called frmLetterDetail ). This main form summarises the Client's
details and the subform gives details of each individual item of
correspondence displayed as single forms rather than continuous
forms..

The arrangement to entering new correspondence is to navigate to the
appropriate Person using the PersonID as the Link criteria and then
have the suform open at a new ( blank) record. This works fine when
the person already has one item of correspondence but I get the get
the error message "No current record" whenever I try to enter the
first item of correspondence. After clearing off the error message it
opens at a blank record on the sbform - just as it should do.

Dim frm As Form 'Reference to the subform.
DoCmd.OpenForm "frmLetterDetail", _
WhereCondition:="PersonID = " & Me.PersonID
Forms!FrmLetterDetail!frmSubDetail.SetFocus

DoCmd.SetWarnings False
DoCmd.GoToRecord , , acNewRec

DoCmd.SetWarnings True

If only I could get these warnings suppressed then I'd be delighted.

When I approach the same result from a different form I get the
message - "You can't go to the specified record". And again, where
the person already has an item of correspondence, then there is no
error message.

Thanks in advance, Yvonne.

Sep 13 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Yvonne wrote:
Hi,

I have this Access 2003 DB that handles Clients and their respective
items of correspondence in a one to many relationship. Clients details
are entered in frmPerson. When it comes to recording an item of
correspondence this is done via another form/subform ( main form is
called frmLetterDetail ). This main form summarises the Client's
details and the subform gives details of each individual item of
correspondence displayed as single forms rather than continuous
forms..

The arrangement to entering new correspondence is to navigate to the
appropriate Person using the PersonID as the Link criteria and then
have the suform open at a new ( blank) record. This works fine when
the person already has one item of correspondence but I get the get
the error message "No current record" whenever I try to enter the
first item of correspondence. After clearing off the error message it
opens at a blank record on the sbform - just as it should do.

Dim frm As Form 'Reference to the subform.
DoCmd.OpenForm "frmLetterDetail", _
WhereCondition:="PersonID = " & Me.PersonID
Forms!FrmLetterDetail!frmSubDetail.SetFocus

DoCmd.SetWarnings False
DoCmd.GoToRecord , , acNewRec

DoCmd.SetWarnings True

If only I could get these warnings suppressed then I'd be delighted.

When I approach the same result from a different form I get the
message - "You can't go to the specified record". And again, where
the person already has an item of correspondence, then there is no
error message.

Thanks in advance, Yvonne.
In the form's property sheet, under Events, there's an OnError event.
You could enter something like
msgbox "SF " & DataErr
in the subform. Change the message for the main form.

If you get that error when you go to new record then you can trap for
it. Like
If DataErr = 1234 then response = acdataerrcontinue

If that helps, it really does not correct the problem...simply hides it.
Sep 13 '07 #2

P: n/a
>
In the form's property sheet, under Events, there's an OnError event.
You could enter something like
msgbox "SF " & DataErr
in the subform. Change the message for the main form.

If you get that error when you go to new record then you can trap for
it. Like
If DataErr = 1234 then response = acdataerrcontinue

If that helps, it really does not correct the problem...simply hides it.- Hide quoted text -

- Show quoted text -
Hi Salad,

'I wasn't quite able to implement your first fix - being a relative
newbie and with the second, the problem doesn't give an error number
so I couldn't trap it.

You got me thinking though and what I have done is take out the MsgBox
Err.Description line in the On Open Event :-
Err_Open_:

'MsgBox Err.Description
Resume Exit_Open_
Hopefully, this will not have too many adverse implications
subsequently!

Thanks, Yvonne

End Sub

Sep 13 '07 #3

P: n/a
Yvonne wrote:
>>In the form's property sheet, under Events, there's an OnError event.
You could enter something like
msgbox "SF " & DataErr
in the subform. Change the message for the main form.

If you get that error when you go to new record then you can trap for
it. Like
If DataErr = 1234 then response = acdataerrcontinue

If that helps, it really does not correct the problem...simply hides it.- Hide quoted text -

- Show quoted text -

Hi Salad,

'I wasn't quite able to implement your first fix - being a relative
newbie and with the second, the problem doesn't give an error number
so I couldn't trap it.

You got me thinking though and what I have done is take out the MsgBox
Err.Description line in the On Open Event :-
Err_Open_:

'MsgBox Err.Description
Resume Exit_Open_
Hopefully, this will not have too many adverse implications
subsequently!

Thanks, Yvonne

End Sub
Yes, that will work. However, you might want to do this instead. Change
MsgBox Err.Description
to
MsgBox err.number & " " & Err.Description

Write the err.number down. Then change the code to

Err_Open_:
if err.number <WhatWasThatNumberYouWroteDown then
MsgBox Err.number & " " & Err.Description
Endif
Resume Exit_Open_

This ignores the current error you have but will trap for other errors
that could occur.

It's handy to know the error numbers. That way if you ever contact this
newsgroup about an error, we can find the error number easier than
searching the errors list for the description.

BTW, the DataErr stuff is something to remember if an error occurs that
is not part of an OnError routine in a sub or function. Go to the
form's property, select Events tab, and find OnError at the bottom of
the list. Click in the row and press F1 to read more about it.
Sep 13 '07 #4

P: n/a
>
Yes, that will work. However, you might want to do this instead. Change
MsgBox Err.Description
to
MsgBox err.number & " " & Err.Description

Write the err.number down. Then change the code to

Err_Open_:
if err.number <WhatWasThatNumberYouWroteDown then
MsgBox Err.number & " " & Err.Description
Endif
Resume Exit_Open_

This ignores the current error you have but will trap for other errors
that could occur.

It's handy to know the error numbers. That way if you ever contact this
newsgroup about an error, we can find the error number easier than
searching the errors list for the description.

BTW, the DataErr stuff is something to remember if an error occurs that
is not part of an OnError routine in a sub or function. Go to the
form's property, select Events tab, and find OnError at the bottom of
the list. Click in the row and press F1 to read more about it.- Hide quoted text -

- Show quoted text -
Salad.

That worked a treat ! The error was 2105 and now is it suppressed.

Many thanks for the most comprehensive and effective response. It is
greatly appreciated.

Yvonne


Sep 13 '07 #5

P: n/a
Yvonne wrote:
>>Yes, that will work. However, you might want to do this instead. Change
MsgBox Err.Description
to
MsgBox err.number & " " & Err.Description

Write the err.number down. Then change the code to

Err_Open_:
if err.number <WhatWasThatNumberYouWroteDown then
MsgBox Err.number & " " & Err.Description
Endif
Resume Exit_Open_

This ignores the current error you have but will trap for other errors
that could occur.

It's handy to know the error numbers. That way if you ever contact this
newsgroup about an error, we can find the error number easier than
searching the errors list for the description.

BTW, the DataErr stuff is something to remember if an error occurs that
is not part of an OnError routine in a sub or function. Go to the
form's property, select Events tab, and find OnError at the bottom of
the list. Click in the row and press F1 to read more about it.- Hide quoted text -

- Show quoted text -


Salad.

That worked a treat ! The error was 2105 and now is it suppressed.

Many thanks for the most comprehensive and effective response. It is
greatly appreciated.

Yvonne
Ahhhh...the old 2105 gotcha! It's one you may want to remember. Let's
say you open a FormB from FormA. And in FormB's OnOpen event you do
some checking and if the validatation doesn't pass you cancel the Open
event. When you return to the sub in FormA that opened FormB you'll get
a 2105 operation canceled message.

If you call subs with a Cancel operation (look at the OnOpen event of
any form, you'll see the word Cancel as an argument) you might want to
display all errors except the 2105. IOW, any subs that call another sub
and that called sub has a Cancel As Integer as one of its arguments.

Sep 13 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.