S
Samuel
Hi,
Could somebody help me better my code? I want to count the length of each
field in a recordset of more than 1 table.
At the moment i manually change the name of the table in the code so i can
count, but i know that this can be done automatically.
I should loop through the tabledefs where the type is odbc linked table, but
i can't managed it.
Here's the code:
Dim rs As DAO.Recordset
Dim rs1 As DAO.Recordset
Dim CC As Long
Dim fd As DAO.Field
Set rs = CurrentDb.OpenRecordset("Select * From table 1")<<<<<this
should be done automatically
Set rs1 = CurrentDb.OpenRecordset("Select * From tblLengths")
Do Until rs.EOF
On Error Resume Next
For Each fd In rs.Fields
With rs1
.AddNew
!FieldName = fd.Name
!Fieldvalue = fd.Value
!FieldLength = Len(fd.Value)
.Update
End With
'Debug.Print fd.Name & " : " & Len(fd.Value)
CC = CC + Len(fd.Value)
Next fd
rs.MoveNext
Loop
Set rs = Nothing
Set rs1 = Nothing
Could somebody help me better my code? I want to count the length of each
field in a recordset of more than 1 table.
At the moment i manually change the name of the table in the code so i can
count, but i know that this can be done automatically.
I should loop through the tabledefs where the type is odbc linked table, but
i can't managed it.
Here's the code:
Dim rs As DAO.Recordset
Dim rs1 As DAO.Recordset
Dim CC As Long
Dim fd As DAO.Field
Set rs = CurrentDb.OpenRecordset("Select * From table 1")<<<<<this
should be done automatically
Set rs1 = CurrentDb.OpenRecordset("Select * From tblLengths")
Do Until rs.EOF
On Error Resume Next
For Each fd In rs.Fields
With rs1
.AddNew
!FieldName = fd.Name
!Fieldvalue = fd.Value
!FieldLength = Len(fd.Value)
.Update
End With
'Debug.Print fd.Name & " : " & Len(fd.Value)
CC = CC + Len(fd.Value)
Next fd
rs.MoveNext
Loop
Set rs = Nothing
Set rs1 = Nothing