473,385 Members | 1,588 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Can't Trap combo box error when null entered

When a user clears a value from a combo box (by pressing the delete key),
the following message appears:

"You tried to assign the null value to a variable that is not a variant data
type".

The problem is that I can't trap the error in the Before Update event. The
error is generated before it gets there. Furthermore, I am not trying to
assign the value to any 'variable' (at least not till the AfterUpdate event)

The combo box is set to 'Limit to List', and has no default value.
Control Source is a Long Integer with a default value of '0'.

Can anyone tell me how to interecept this error message?

(Using Access 2002 on Win XP Pro.)

--
Bob Darlington
Brisbane
Nov 13 '05 #1
2 8430
Open the table where the field resides, and check if its Required property
is Yes.
If so, it is an engine-level error, so trap it in the Error event of the
Form.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Bob Darlington" <bo*@dpcmanAX.com.au> wrote in message
news:42**********************@news.optusnet.com.au ...
When a user clears a value from a combo box (by pressing the delete key),
the following message appears:

"You tried to assign the null value to a variable that is not a variant
data type".

The problem is that I can't trap the error in the Before Update event. The
error is generated before it gets there. Furthermore, I am not trying to
assign the value to any 'variable' (at least not till the AfterUpdate
event)

The combo box is set to 'Limit to List', and has no default value.
Control Source is a Long Integer with a default value of '0'.

Can anyone tell me how to interecept this error message?

(Using Access 2002 on Win XP Pro.)

--
Bob Darlington
Brisbane

Nov 13 '05 #2
Thanks Allen,
The 'Required' property was 'No', but your solution worked anyway using:

Dim strControl As String

strControl = Screen.ActiveControl.Name

If DataErr = 3162 Then
If MsgBox("You must enter a value for this field. It cannot be left
blank." _
& vbCrLf & "Press OK to continue or Cancel to abort.", 1) =
2 Then
Me.Undo
Else
Me(strControl).Undo
End If
Response = acDataErrContinue
End If

I had always thought that I could trap null values in a control's
BeforeUpdate event.
But the BeforeUpdate sub isn't even addressed before the Form_Error decided
to involve itself.
Is this because it is a combo box?

--
Bob Darlington
Brisbane
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:42***********************@per-qv1-newsreader-01.iinet.net.au...
Open the table where the field resides, and check if its Required property
is Yes.
If so, it is an engine-level error, so trap it in the Error event of the
Form.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Bob Darlington" <bo*@dpcmanAX.com.au> wrote in message
news:42**********************@news.optusnet.com.au ...
When a user clears a value from a combo box (by pressing the delete key),
the following message appears:

"You tried to assign the null value to a variable that is not a variant
data type".

The problem is that I can't trap the error in the Before Update event.
The error is generated before it gets there. Furthermore, I am not trying
to assign the value to any 'variable' (at least not till the AfterUpdate
event)

The combo box is set to 'Limit to List', and has no default value.
Control Source is a Long Integer with a default value of '0'.

Can anyone tell me how to interecept this error message?

(Using Access 2002 on Win XP Pro.)

--
Bob Darlington
Brisbane


Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Robertico | last post by:
Hi, Is it possible to trap a (web)server error (e.g. 404) with php. I have one custom error page (php) for all the server errors. So i want to know with error number occurs. Regards, ...
4
by: Doo-Dah Man | last post by:
I hope this is the right group for this question, if it's not please direct me. I have a data-driven website that allows users to enter records for sales leads. It all works perfectly. The...
1
by: Marco Krechting | last post by:
Hi All, This is a response on my earlier posting about trapping the standard access error message when you click on a hyperlink field and the file cannot be found. I know now how to work on the...
5
by: MLH | last post by:
I get error 3315 when attempting to enter ZLS into a text-type table field whose allow zls property is set to false. The error says "Field MyTable.MyField can't be a zero-length string" For...
25
by: moondaddy | last post by:
I have an application where users need to upload images and in my web.config file I have a setting like this: <httpRuntime maxRequestLength="512" /> Which restricts image larger than 500k from...
9
by: Ron | last post by:
my application is throwing an exception error when closing if I run a procedure in the app. I can't even trap the error with try/catch ex As Exception. Is there a way to completely shut down the...
1
by: suslikovich | last post by:
Hi all, I am getting this error when insert values from one table to another in the first table the values are varchar (10). In the second they are datetime. The format of the data is mm/dd/yyyy...
3
by: =?Utf-8?B?UXVpbWJseQ==?= | last post by:
Preamble: Users table: UserID int, PK, not null .... CultureID int, FK, null Cultures table: CultureID int, OK, not null ....
2
by: ilany | last post by:
Hi to all... Would greatly appreciate any suggestions. I'm trying to evaluate an expression during run-time that looks something like this: ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.