473,407 Members | 2,314 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,407 software developers and data experts.

How to make access use empty string instead of NULL

I have a table in SQLServer with a varchar field set to NOT NULL, with a default value of the empty string. This table is linked in access, and the field is linked to a text box on a form. When I attempt to edit that field, all is good unless I need to delete everything in the text box and return it to the default state of the empty string, Access complains: "You tried to assign the NULL value to a variable that is not a variant data type". I try to edit the field from the table directly (in access) and I get the same error when attempting to set it to the empty string. I would like to know if there is any way to get access to use the empty string instead of NULL in this situation? I'd rather not resort to MS's suggestion of allowing NULLs and then just pretending that "" and NULL are the same. Any ideas?
Jul 29 '10 #1
5 8360
patjones
931 Expert 512MB
I just duplicated your situation using SQL Server Management Studio and got exactly the same message. What is even more interesting is that when I modify the column on the SQL Server side to allow nulls, the error persists.

Looking in other forums online, I am finding lots of people who received this message - but it was usually in the context of using a form for the data entry. The workaround appears to be to check in the text box's After Update event to make sure the form isn't passing a null to the table.

However, in my test, I was attempting to modify the record directly in the Access table. Fundamentally, it seems to me that if the column is set to allow nulls on the SQL Server side, and then I go and and completely delete an entry in a column on the Access side...it should let me do it.

I will try and research it some more. In the meantime, others here on the forum may have an idea.

Pat
Jul 30 '10 #2
I eventually started thinking that using the After Update event might work, at least for the form side of things. Which for my purpose would be adequate, since I'm only concerned about the user's experience. I can manually run an UPDATE statement if I need to. But since this was a project for my job, I didn't want to spend any more time on it than was necessary, so I just went the way of allowing nulls. Maybe I'll try the After Update solution next time.
Jul 31 '10 #3
patjones
931 Expert 512MB
I was about to say that you should just allow nulls when I responded to you the other night, but that was before I actually did allow nulls and still got the message.

The error did in fact disappear for you after allowing nulls on the SQL Server side?

Pat
Jul 31 '10 #4
patjones
931 Expert 512MB
Actually it does work just fine for me when I allow nulls in the SQL Server table design. A little bit of confusion about column names on my part ;)

Pat
Jul 31 '10 #5
NeoPa
32,556 Expert Mod 16PB
I think a lot of the confusion here arises from the controls used. Controls are not really typable per-se. They can be bound to typed fields, but in all cases they will interpret an empty control as a Null (No quotes used even for strings when entering data). There's no reliable way to differentiate between an empty string ("") and Null from the perspective of a form control, and even numeric entries are treated as strings that just get converted when assigned to the underlying field.
Jul 31 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Gidi | last post by:
hello, i have a textbox that represnts a date and i want to pare it to a DateTime, but sometimes this textBox can be empty string and i want to send it to the DataBase as null or as empty Date, how...
5
by: VMI | last post by:
How can I validate a null string or an empty string in the same IF statement? If I use this: if (myString.Trim().Length <= 0 || myString == null) { //do stuff } I'll get a run-time error...
11
by: Dan Bass | last post by:
which one do you use and why? MyString == null || MyString == "" vs MyString == null || MyString.Length == 0
4
by: web1110 | last post by:
I have an array of of 5 string elements. I put values in 3 of them. Yet when I loop over them, I do not catch the empty string. The code output below does not include "Empty" stringx=new...
1
by: Raed Sawalha | last post by:
how can I ignore public empty string from being displayed in generated xml the empty string displayed as - <language> <CharacterString /> </language> i need if the string is empt to not be...
26
by: Neville Lang | last post by:
Hi all, I am having a memory blank at the moment. I have been writing in C# for a number of years and now need to do something in VB.NET, so forgive me such a primitive question. In C#, I...
1
by: amolc | last post by:
Hi, Can you Please Tell me What is difference between NULL string and EMPTY string?
4
by: Jay | last post by:
For a column that contains a string (let's say varchar), is there any performance advantage in not allowing nulls, and using an empty string ("") to instead?
2
by: Jay | last post by:
I have a SQL Server table with nvarchar type column which has not null constraint. I am inserting empty string ("") from Java to the table column. When I export this table into .csv file using bcp...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...

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.