Link to home
Start Free TrialLog in
Avatar of DaveHa
DaveHa

asked on

Print text - viewmdb

Any idea about this?
Syntax:
 Printer.Print Tab(5); "Fields:"
    Printer.Print Tab(5); "------"
    For Each fd In td.Fields
    Printer.Print Tab(5); "["; Left(fd.Name + "]" + Space(20), 20) + Left(Str(fd.Size) + Space(5), 6) + typetable(fd.Type)
Printer.Print , " Description: "; fd.Properties("; Description; "); ""
    Next fd

It should look like this:

Fieldname  Fieldsize Datatype
---------- --------- ---------
CustomerID    4     Integer  

Description:
Some description here for every field...
.....

Thanks for help!
/Dave
ASKER CERTIFIED SOLUTION
Avatar of mcrider
mcrider

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
One thing you should think about is that the description property for a field does not exist if there is no description, therefore if you  are using :

    For Each fd In td.Fields
        Debug.Print Tab(5); "["; Left(fd.Name + "]" + Space(20), 20) + Left(Str(fd.Size) + Space(5), 6) + CStr((fd.Type))
        Debug.Print , " Description: "; fd.Properties("description"); ""
    Next fd

You should also have some error handling to allow for an error on the fd.properties.

Such as

Private Sub Command1_Click()
    Dim accDB As Database
    Dim td As TableDef
    Dim fd As DAO.Field
    Set accDB = OpenDatabase("c:\testbed\cremosa.mdb")
    Set td = accDB.TableDefs("graphics")
    Debug.Print Tab(5); "Fields:"
    Debug.Print Tab(5); "------"
    For Each fd In td.Fields
        Debug.Print Tab(5); "["; Left(fd.Name + "]" + Space(20), 20) + Left(Str(fd.Size) + Space(5), 6) + CStr((fd.Type))
        Debug.Print , " Description: "; GetFDProp(fd, "Description"); ""
    Next fd
End Sub

Private Function GetFDProp(fdFieldDef As DAO.Field, strProperty As String)
    On Error GoTo errProperty
    strValue = fdFieldDef.Properties(strProperty)
    GetFDProp = strValue
    Exit Function
   
errProperty:
    strValue = "Property Value Unavailable"
    Resume Next
End Function
Avatar of mark2150
mark2150

You should email me direct on this!

Mcrider, the Courier New font was selected earlier in the code...

M
mark2150,

How do you know Courier New was selected earlier in the code?  No reference was made in this question of it.


Cheers!
Avatar of DaveHa

ASKER

Yes mcrider Courier New is selected earlier in the code.
Ok Mark!

Dave
mcrider,

Perhaps it's 'cause *I* wrote the ViewMDB program he's asking about...

M