Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format Column Width of a Query (with code)?

Status
Not open for further replies.

billschu

Technical User
Apr 3, 2001
38
US
Hi,

I'm looking to do some formatting to a query through code, specifically, widening some of the columns (or doing an Autofit).. you can do this through the Format menu once the query is open, but I want to do it with VB. I investigated the properties for the querydef object, but couldn't find anything to manipulate the column widths.

Thanks,
Bill
 
Hi BillMe,

You want to use the ColumnWidth Property of the Field to set the width in twips (1440 twips to the inch), for example

Code:
[blue]QueryDefs![i]MyQuery[/i].Fields![i]MyField[/i].Properties!ColumnWidth = 2880[/blue]

Note two special values ..

0 means column is hidden, and
-1 means it is the default width

Enjoy,
Tony

------------------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading FAQ222-2244 before you ask a question.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top