467,075 Members | 997 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,075 developers. It's quick & easy.

making an error more meaningful....

Hi,

I am trying to make errors a bit more meaningful for my users.

I am trying to fix error 3201 where there is a missing field in a form.

If I do not do any error trapping, then I get

You cannot add or change a record because a related record is required in
table 'my table name'.

All I wanted to do is to change my table name to something more meaningful
in onerror event. However, when I access the message there, I get:

You cannot add or change a record because a related record is required in
table '|'.

Does anyone know how this works?

TIA

- Nicolaas
Nov 13 '05 #1
  • viewed: 1801
Share:
3 Replies
I am new to this group, but here are a few links that I found when I
searched on "error 3201", hopefully they might help.

http://groups-beta.google.com/group/...bf0685a81b7cd8

this person was nice enough to post their solution: (close to the
bottom, same error statement you recieved.)
http://groups-beta.google.com/group/...4f5503179589d4

Nov 13 '05 #2
windandwaves wrote:
Hi,

I am trying to make errors a bit more meaningful for my users.

I am trying to fix error 3201 where there is a missing field in a form.

If I do not do any error trapping, then I get

You cannot add or change a record because a related record is required in
table 'my table name'.

All I wanted to do is to change my table name to something more meaningful
in onerror event. However, when I access the message there, I get:

You cannot add or change a record because a related record is required in
table '|'.

Does anyone know how this works?

TIA

- Nicolaas

Since I'm not sure where it's called...
In the forms OnError event, maybe something like
If Dataerr = 3021 then
or in a OnError event
If Err.Number = 3021 then
and then put in the error message of your own fashion. Will that work?

3021 seems to be about a current record not being available.
Nov 13 '05 #3
Salad wrote:

[snip] [snip] [snip] [snip] [snip] [snip]

thank you both for your comments...

Here is the final function I wrote:

Public Function FMFEH(n) As Long
'form most frequent error handling
'On Error GoTo er
'-
Dim FRM As Form
Dim Ctl As Control
Dim S As String
Dim C As Long
Dim FldD As String
Dim FldN As String
Dim OK As Boolean
'-
FMFEH = True
Select Case n
Case 3201, 3314
S = FINTXT(307) & vbCr & vbLf & vbCr & vbLf
C = 0
If Not (SCFAF Is Nothing) Then
Set FRM = SCFAF
For Each Ctl In FRM.Section(0).Controls
If eCount("[ID]", "[T-TFC]", "[T-TFC]![T-TFD-ID]=" &
TabDctoID(Ctl.NAME, "T-TFD") & " AND [T-TFC]![T-TAB-ID]=" &
TabDctoID(FRM.Tag)) = 1 Then ' T-TFC = a table in which I store data about
the fields, here i check for an entry
If Ctl.Visible = True Then
If Ctl.Width > 0 Then
If NZZ(Ctl.Value) = False Then
Select Case Ctl.ControlType
Case acComboBox
If Ctl.LimitToList = True Then
OK = True
Else
OK = False
End If
Case acTextBox
If eLookup("[UNI]", "[T-TFC]", "[T-TFC]![T-TFD-ID]="
& TabDctoID(Ctl.NAME, "T-TFD") & " AND [T-TFC]![T-TAB-ID]=" &
TabDctoID(FRM.Tag)) = True Then ' T-TFC = a table in which I store data
about the fields' requirements (e.g. unique index combo)
OK = True
Else
OK = False
End If 'other stuff
Case Else
OK = False
End Select
Else
OK = False
End If
If OK = True Then
FldD = eLookup("[D]", "[T-TFC]", "[T-TFC]![T-TFD-ID]=" &
TabDctoID(Ctl.NAME, "T-TFD") & " AND [T-TFC]![T-TAB-ID]=" &
TabDctoID(FRM.Tag)) ' T-TFC = a table in which I store data about the
fields' names
If C > 0 Then
S = S & " AND ALSO "
C = C + 1
End If
S = S & FldD & vbCr & vbLf & vbCr & vbLf
Ctl.OnLostFocus = "=CRBAE(" & Ctl.BorderColor & ")"
Ctl.BorderColor = RGB(255, 0, 0)
End If
End If
End If
End If
Next Ctl
End If
msgbox S
FMFEH = False
Case 3022
msgbox "info about duplicate records"
FMFEH = False
Case Else
FMFEH = True
End Select
xt:
Exit Function
er:
FMFEH = True
Resume xt
End Function
===============================
and I add the following to each form
===============================

for each frm in ....

set frm = ..

set mdl = frm.module
x = 1
MDL.InsertLines x, "option compare database": x = x + 1
MDL.InsertLines x, "Option Explicit": x = x + 1
MDL.InsertLines x, "Private Sub Form_Error(DataErr As Integer, Response
As Integer)": x = x + 1
MDL.InsertLines x, " Response = FMFEH(DataErr)": x = x + 1
MDL.InsertLines x, "End Sub": x = x + 1

next frm
Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Joshua Ellul | last post: by
351 posts views Thread by CBFalconer | last post: by
7 posts views Thread by jacob navia | last post: by
12 posts views Thread by Ron M. Newman | last post: by
2 posts views Thread by Srini | last post: by
18 posts views Thread by pereges | last post: by
14 posts views Thread by Mike Copeland | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.