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

CRISIS! How to programatically alter a back-end table field property?

Hi folks,

I just discovered that I have a table with a bunch of text fields that
ALL have the "Allow Zero Length" property set to "No", which is
apparently the default when you create a new text field. Please
correct me if I'm wrong about this. Somehow (I'm clueless about how),
some of my user's records have ended up with zero length strings in
some of these fields -- despite the restriction. The restriction is
not important to the application. But, now, when I execute a query to
move records from one table to another one with identical structure,
the query fails with the error: "1 or more records were not inserted
due to validation rule violations." There are NO, repeat N O fields
with validation rules set. However, when I manually change the "Allow
Zero Length" property for each of the text fields in the target table
to "Yes", the query works perfectly for all inserted records.

If this IS the cause of the problem, the obvious next question is: Is
there a way to programmatically change the "Allow Zero Length"
property of a text field in a linked back-end table FROM the front end
data base?

Please folks, this is a major crisis for my company. I'll be
eternally grateful for any advice on this problem.

Cheers!

Nov 12 '05 #1
2 5303
> If this IS the cause of the problem, the obvious next question is: Is
there a way to programmatically change the "Allow Zero Length"
property of a text field in a linked back-end table FROM the front end
data base?


You can, but have you considered just using an update query to replace each
zero-length entry ("") with "Null"?

--
Bruce M. Thompson, Microsoft Access MVP
bt******@mvps.org (See the Access FAQ at http://www.mvps.org/access)
NO Email Please. Keep all communications

within the newsgroups so that all might benefit.<<
Nov 12 '05 #2
On Tue, 25 Nov 2003 11:48:41 -0600 in comp.databases.ms-access,
LaurenW <re**********@nospam.zap> wrote:
Hi folks,

I just discovered that I have a table with a bunch of text fields that
ALL have the "Allow Zero Length" property set to "No", which is
apparently the default when you create a new text field. Please
correct me if I'm wrong about this. Somehow (I'm clueless about how),
some of my user's records have ended up with zero length strings in
some of these fields -- despite the restriction.
It's possible the restriction was lifted by a rougue programmer to
suit him/herself then put back again. I had a programmer who had
problems deleting test data due to RI violations so he stripped every
relationship out of the database. Actually, more than one, but at
least one I managed to find out before it went into production and
stood over the culprit while he put the relationships back in. The
other wasn't caught in time and caused major headaches.
The restriction is
not important to the application. But, now, when I execute a query to
move records from one table to another one with identical structure,
the query fails with the error: "1 or more records were not inserted
due to validation rule violations." There are NO, repeat N O fields
with validation rules set. However, when I manually change the "Allow
Zero Length" property for each of the text fields in the target table
to "Yes", the query works perfectly for all inserted records.

If this IS the cause of the problem, the obvious next question is: Is
there a way to programmatically change the "Allow Zero Length"
property of a text field in a linked back-end table FROM the front end
data base?

Please folks, this is a major crisis for my company. I'll be
eternally grateful for any advice on this problem.


It's not generally good practice to go modifying the schema on the fly
from the front end but here's a function you could run in your back
end:

Function AllowZLS()
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field

Set db = CurrentDb()
For Each tdf In db.TableDefs
If Not tdf.Name Like "MSys*" And Len(tdf.Connect) = 0 Then
For Each fld In tdf.Fields
With fld
If .Type = dbText Then
If Not .AllowZeroLength Then
.AllowZeroLength = True
End If
End If
End With
Next
Set fld = Nothing
End If
Next
Set tdf = Nothing
Set db = Nothing

End Function

If you absolutely must run from the front end then replace CurrentDb()
with a OpenDatabase() and add a db.close just before setting to
nothing.

Also, read Bruce's suggestion, having tables with nulls and Zero
length strings can cause mayhem when querying the table, the results
can be unpredictable (actually, I could predict them as I know how
nulls work in comparisons, or not as the case is) buit even with the
prediction it's a lot more work to query them. It's easy for the
computer to tell the difference between a null and a zero length
string but more difficult to the human eye.

--
A)bort, R)etry, I)nfluence with large hammer.
Nov 12 '05 #3

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

Similar topics

47
by: Daniel Silva | last post by:
Shriram Krishnamurthi has just announced the following elsewhere; it might be of interest to c.l.s, c.l.f, and c.l.p: http://list.cs.brown.edu/pipermail/plt-scheme/2005-April/008382.html The...
3
by: Dark Cowherd | last post by:
Hi, Multiple threads running currently about reinventing the wheel, Multiple GUI's etc. Being able to write a usable GUI is key task for all programmers today - read. ESR's...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
14
by: Gotisch | last post by:
Hi, we are currently writing an mostly singlethreaded (game)server application in c#. But we are encountering problems with the Garbage Collector: After a certain time but also apparently...
3
by: ronrsr | last post by:
is the error message I'm getting here, on the long formatted print statement. . I've tried adding arguments, in case I missed one, and it still gets a syntax error. here's the info: #row is...
28
by: Everyman | last post by:
I don't think it's too much of an exaggeration to say that the Jacob situation is reaching crisis proportions for clc. Just imagine the view a new poster gets of the group: he asks a question,...
14
by: Logan Lee | last post by:
int main() { int i; char c; void *the_data; i = 6; c = 'a';
0
by: jiggsroger | last post by:
Hello there! I am trying to build an application here which I have to produce for my examination in a few days. A part of the appearance of the project requires me to use two listviews. The working...
1
by: Christina123 | last post by:
I don't actually need the code for this...yet. Essentially I need to know if what I want to do can be done. I have two work books. One is a report the other contains the data that the report is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
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
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.