Print text - viewmdb

Any idea about this?
 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  

Some description here for every field...

Thanks for help!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

If you want to use tab characters like you have in your example, you need to use a non-proportional font, like Courier-New.  You get a more predicable output.

Otherwise, you can set the printer's CurrentX and CurrentY locations before printing each item.  That way you get more control over what gets printed where.

Using the printer's TextHeight and TextWidth functions will let you know how much space will be taken up by the string you intend to print...


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TimCotteeHead of Software ServicesCommented:
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

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
    strValue = "Property Value Unavailable"
    Resume Next
End Function
You should email me direct on this!

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

Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.


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

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


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

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.