Combine portions of Microsoft message with my customized error message

T

Tom

I have a form that contains several (REQUIRED) combo boxes and 2 subforms.

Currrently,
- each combo box must be completed in order to save the record
- also, I'm not "allowed" add values to the subforms unless all of required
combos have been completed (even though I wouldn't mind if I could values to
subforms w/o completing all required combos)

Now, right now, if I forgot to select a value and attempt to add a record to
either subform, I get the following message:

"You cannot add or change a record because a related record is required in
the table 'MyTableName'." I kind of like this message since it does give
me the table name.

However, I'd rather have a customized message that would give me my
particular "FieldName". For testing purposes, I added the OnError
function (as shown below) to my form. So, naturally, I now get my
customized message. However, it doesn't give me any indication about the
table name (nor field name)... bummer.

So, here's my question.... how can I combine both? ... using my customized
message but include the actual field name. For instance, given the
"mistakes" below, a message box like this would be great:

If mistake = I forgot to select values of combos "Division" and "Resource
Category", then my customized message should e.g. look like this:

"No values for fields 'Division' and 'Resource Category' have been
selected!"

Any ideas how to make the "connection" (>>Microsoft's message indicator of
table name<< to >> my customized message listing missing field name<<)?

Tom

= Current generic customized message does not give me any clues as to what
was not selected =

Private Sub Form_Error(DataErr As Integer, Response As Integer)

'Prevents the Access default message to pop up
If DataErr = 3201 Then
MsgBox "You forgot to select some values for required combos!"
Response = acDataErrContinue
End If

End Sub
 
Top