"Allow Zero Length"

W

William Kossack

I've got a program working to create an access table using Cold Fusion
now another problem has come up.

How do you set the "Allow Zero Length" option for an access field during
an sql create query? Or is there some other way of changing
the option value?
 
A

Allen Browne

William, the simplest way to achieve this is to use Access 97, where the
Allow Zero Length (AZL) property always defaults to No, the value you should
use, so there is no confusion trying to differentiate between Null and a
Zero-Length String (ZLS).

Believe me, users cannot tell the difference, many developers cannot tell
the difference, and Access itself cannot the difference correctly, e.g.
DLookup() wrongly returns Null for a field that contains a ZLS.

The later versions are inconsistent in the setting of the property,
depending whether the table was created via the interface, a DLL query
statement, DAO, or ADOX. Can't remember the results, but if you experiement
with the 4 approaches, you will find some of them have AZL turned on.

If you actually want to control the AZL property, you must use DAO. The code
looks like this:

Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field

Set db = CurrentDb()
Set tdf = db.TableDefs("MyTable")

For Each fld In tdf.Fields
Select Case fld.Type
Case dbText, dbMemo
fld.AllowZeroLength = False
End Select
Next

Set fld = Nothing
Set tdf = Nothing
Set db =Nothing
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top