Solved

DAO/ADO/Access97/Access2000 and NULLS!!!! (Information only)

Posted on 2001-06-22
4
165 Views
Last Modified: 2010-05-02
Lo again,

    another quick question conserning DAO and ADO connected to a MS Access 2000 DB
   Using DAO and setting  text boxes up with whatever data is in the fields from a recordset is fine.
   Using ADO however causes an invalid use of null error when setting the exact same record to the text boxes.
   Why is this?, does this mean that I need to check each record for the existence of nulls before setting the
   text boxes?, which is what Im doing now (pain in the butt!)
  quick thought : Ive also converted from Access97 to Access2000, Could this be the difference? and not DAO/ADO?


Cheers
Ben
0
Comment
Question by:BBaron
4 Comments
 
LVL 18

Accepted Solution

by:
deighton earned 50 total points
Comment Utility
if setting a database field then if the field property is 'allow zero length field = false then you can not put "" in it, you must put in at least one character.

If returning a field to a string then do

text1.text = rsRecordset("field") & ""  'as a fix to avoid nulls
0
 
LVL 2

Expert Comment

by:idorey
Comment Utility
You can also use the format command to avoid this problem:

Whatever = Format(AnotherStringValue)

If AnotherStringValue is a Null, this will prevent the error.

Good Luck
0
 
LVL 9

Expert Comment

by:Valliappan AN
Comment Utility
Also, if your field's Required property is set to True, then you could not insert a record, without passing a value to the particular field.

But to our experience, setting Required to False, and Allow Zero Length to True, is a flexible one.

You could use deighton's one to handle with Null values. Not only for text box, wherever you might need it.

Another option, I dont know if this is viable to you or not:
When saving the records, itself, you dont save records with Null values, pass an empty string, instead. And for the existing data in tables, you do an UPDATE statement, to replace all the NULLs with empty string.

Cheers.
0
 

Author Comment

by:BBaron
Comment Utility
Cheers buddy, thats easier than using if isnull all the time!!!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now