Default Error Messages

khurram7x

Registered User.
Local time
Tomorrow, 03:58
Joined
Mar 4, 2015
Messages
226
how to change Access default error messages with custom messages?
Like, if I enter some data in a sub form where the parent form is empty new record, default error message says that 'You must enter a value in the 'column name' field'.

I want to disable this default message and display my own error message.
Now I know MessageBox and MsgBox fuctions to display custom messages, but how to disable the default message please.
 
Like, if I enter some data in a sub form where the parent form is empty new record,
This error is not raised in VBA code, where you might be able to handle it and provide some other message. This error is raised at the table level when the subform manages the record addition for you, and when there is no parent record to which the subform should link the new record. So there is no easy way to swap this message out for a different one. Rather, what I would do, is try to make it impossible for the user to enter data into the subform prior to there being a valid record in the main form, for instance, handle the Current event of the main form, and check Me.NewRecord, or check if the primary key is null. If so, disable additions in the subform, and then this error can't occur.

Hope this helps
 
...for instance, handle the Current event of the main form, and check Me.NewRecord, or check if the primary key is null. If so, disable additions in the subform, and then this error can't occur.
Hope this helps
Thank you, got it working by using both Me.NewRecord via VBA, and IF [Form].ID IS NULL THEN via Macro.

Only I couldn't get it working if i try to check Null value of [Form].ID via VBA. I tried to use same IF and NULL combination as in Macro and IsNull() but VBA compiler gives debug error, and the same thing works fine with Macro. How could we check Null values from VBA please?
I tried in VBA editor as:
1st attempt: IF Me.ID IS NULL THEN
Alternate attempt: IF ISNULL(Me.ID) THEN

Thanks.
 
This should work . . .
Code:
IF IsNull(Me.ID) Then
. . . and if it doesn't, as with any error, please cite the error message. One thing that could go wrong with that line is that the object referred to by Me does not contain a member called ID.

Also, you don't need to test for both NewRecord and IsNull(<your record id>). Those are just a couple of options you could use.
 
This should work . . .
Code:
IF IsNull(Me.ID) Then
. . . and if it doesn't, as with any error, please cite the error message. One thing that could go wrong with that line is that the object referred to by Me does not contain a member called ID.

Also, you don't need to test for both NewRecord and IsNull(<your record id>). Those are just a couple of options you could use.
From your reply it sounds like format IsNull(Me.ID) is right, but something is wrong with the processing. Your first reply sorted my problem. Thanks for that.

About Me.ID doesn't exist... well, it exists... and also when i type 'Me.. intellisearch automatically shows 'ID'.
It was understood from your first reply that it is either Primary Key or NewRecord, so this is ok )
 
So everything is solved then?
 

Users who are viewing this thread

Back
Top Bottom