[AccessD] Setting/ retrieving Field properties? Solved! (+code)

S D accessd667 at yahoo.com
Thu Mar 11 02:24:39 CST 2004


Thnx for the replies. I've got it working!
Sub SetAllowZeroLenght(strTablename As String, strFieldName As String, blnValue As Boolean)
   Dim db As DAO.Database
   Dim intI As Integer
   Dim intJ As Integer
   Dim tdf As DAO.TableDef
   Dim fLd As DAO.Field
   Dim dtmDate As Date
   Dim strValue As String
   
   Set db = CurrentDb()
   
   For intI = 0 To db.TableDefs.Count - 1
      Set tdf = db.TableDefs(intI)
      If UCase(tdf.Name) = UCase(strTablename) Then
         dtmDate = Format(Date, "dd mmmm yyyy mm:hh:ss")
         strValue = "Printing properties for table: [" & tdf.Name & "]"
         db.Execute ("INSERT INTO tLog VALUES(#" & dtmDate & "#," & "'" & strValue & "'" & ")")
         Debug.Print "-------------------------------------------------------"
         Debug.Print "Printing properties for table: " & tdf.Name
         Debug.Print "-------------------------------------------------------"
         For intJ = 0 To tdf.Fields.Count - 1
            Set fLd = tdf.Fields(intJ)
            If UCase(fLd.Name) = UCase(strFieldName) Then
               Debug.Print fLd.Name, fLd.AllowZeroLength
               Debug.Print ""
               Exit Sub
            End If
         Next intJ
      End If
   Next intI
End Sub


MartyConnelly <martyconnelly at shaw.ca> wrote:
Here is an example that resets all fields in all tables to allow zero 
length, skips around errors with on error resume next
ACC: How to Set AllowZeroLength Property to Yes in All Tables
http://support.microsoft.com/default.aspx?scid=kb;en-us;130336&Product=acc

S D wrote:

>Hi group,
> 
>I need to set the field properties of a lot of tables. I want to do this using VBA.
>I was reading Access 2000 Developers Handbook and I found the code printed below. However these are not the properties I expected. 
>I need to set field properties like:
>Fiel Size
>Required
>Allow Zerow Length
> 
>Any idea how I can do this?
> 
>TIA
> 
>Sander
> 
> 
>Private Sub Command0_Click()
> Dim db As DAO.Database
> Dim intI As Integer
> Dim tdf As DAO.TableDef
> 
> Set db = CurrentDb()
> 
> For intI = 0 To db.TableDefs.Count - 1
> Set tdf = db.TableDefs(intI)
> If tdf.Name = "V3_44_RSDTD1" Then
> Debug.Print "Printing properties for table: " & tdf.Name
> Call ListTableProps(tdf.Name)
> MsgBox "Properties listed!"
> End If
> Next intI
> 
> MsgBox "Done! Tables found: " & intI
> 
>End Sub
>Sub ListTableProps(strTable As String)
> Dim db As Database
> Dim tdf As TableDef
> Dim prp As DAO.Property
> 
> Set db = CurrentDb()
> Set tdf = db(strTable)
> 
> For Each prp In tdf.Properties
> Debug.Print prp.Name, prp.Type, prp.Value
> Next prp
>End Sub
>
>
>---------------------------------
>Do you Yahoo!?
>Yahoo! Search - Find what youre looking for faster.
> 
>

-- 
Marty Connelly
Victoria, B.C.
Canada



-- 
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

---------------------------------
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster.


More information about the AccessD mailing list