Results 1 to 4 of 4
  1. #1
    Lounger
    Join Date
    Jul 2002
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    DAO does not get correct value of AllowZeroLength (Access 2003)

    I am using the function below to change the AllowZeroLength property to No for all text fields in all tables. For some reason, the function sometimes bypasses fields where I have not manually set the value of the property to Yes (or at least I think that is what is happening). In these cases, DAO reports that the value is No (I have verified this) even though when I look in the table design, it is actually Yes. However, if I manually change the value of the property to No and save, then back to Yes and save, THEN the function will recognize the Yes value and change it to No. Why is this happening? Is there a way to accurately determine via code the actual value of the AllowZeroLength property for all fields in all tables?

    Function FixZLS()
    Dim db As dao.Database
    Dim tdf As dao.TableDef
    Dim fld As dao.Field
    Dim prp As dao.Property
    Const conPropName = "AllowZeroLength"
    Const conPropValue = False

    Set db = DBEngine(0)(0)
    For Each tdf In db.TableDefs
    If (tdf.Attributes And dbSystemObject) = 0 Then
    For Each fld In tdf.Fields
    If fld.Properties(conPropName) Then
    Debug.Print tdf.Name & "." & fld.Name
    fld.Properties(conPropName) = False
    End If
    Next
    End If
    Next

    Set prp = Nothing
    Set fld = Nothing
    Set tdf = Nothing
    Set db = Nothing
    End Function

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: DAO does not get correct value of AllowZeroLength (Access 2003)

    Could you attach a small sample database with one or two tables that illustrate your problem? The tables don't need to contain any records. See <post#=401925>post 401925</post#> for instructions on attaching a database.

  3. #3
    Lounger
    Join Date
    Jul 2002
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DAO does not get correct value of AllowZeroLen

    Hans,
    I tried importing the problem tables into a new database so that I could attach it to my post, but i was not able to replicate the problem in the new database. I wonder if the original database is corrupted. Compact and repair does not resolve the problem.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: DAO does not get correct value of AllowZeroLen

    Perhaps there is a problem with your database - importing into a blank new database is often (but not always, of course) a good way to solve problems.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •