473,804 Members | 2,271 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8445
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.c om.au> wrote in message
news:42******** **************@ news.optusnet.c om.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.ActiveCo ntrol.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 = acDataErrContin ue
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*********@Se eSig.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.c om.au> wrote in message
news:42******** **************@ news.optusnet.c om.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
1665
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, Robertcio
4
2209
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 only thing I want to do right now is prohibit users from entering the same lead twice. I have a PK field in the MS Access database that, obviously, disallows duplicate records. However, when such an attempt is made, the browser redirects to some...
1
323
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 field to use multiple hyperlink bases but I still need a way to get rit of this error message. Can I have a error trap at form level? Or is there another way of dealing with it?
5
2994
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 sure, this is what I expected, entering into a table. The same 3315 error occurs if you try to enter "" into a bound textbox control on a form (bound to the same field. I expected that too.
25
17225
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 being uploaded. I'm also using the HtmlInputFile control to do the uploading. My problem is that when the user's file size exceeds 512k, the page immediately redirects to the "The page cannot be displayed" error page which is very confusing. ...
9
2105
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 app through code? I am using End for now. Is there a way I can suppress this exception message? The app gets invoked programmatically on a schedule. So no one would be around to click off the
1
5480
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 to be easily converted to dates. The conversion in this case is implicit as indicated in SQL Server documentation. Here is my query: INSERT INTO Campaign (CampaignID, Name, DateStart, DateEnd, ParentID, ListID) SELECT ...
3
1708
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
4534
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: Eval("RecordAdd_Addresses(False,"John","","Doe","New York","NY","11216","US","12345678","","",Empty,Empty,Empty)") I get this error:
0
9714
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10347
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9173
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7635
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6863
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5531
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4308
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3832
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.