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!

ColumnWidth Property For Querydef not Working

Status
Not open for further replies.

billschu

Technical User
Apr 3, 2001
38
US
Hi,

I am trying to do some formatting for a query through code - specifically, formatting the column widths so they are not too wide or narrow.

Here is the code I have so far:

Dim qdf1 As DAO.QueryDef
Dim fld1 As DAO.Field

Set qdf1 = CurrentDb.QueryDefs("Delivery Performance")

For i = 0 To qdf1.Fields.Count - 1
Set fld1 = qdf1.Fields(i)
fld1.CreateProperty "ColumnWidth", dbInteger
fld1.Properties("ColumnWidth") = 2000
Set fld1 = Nothing
Next i

The problem is that it acts very strangely and inconsistently - it works for the first two fields but then I get an error that says "Property not found". Sometimes it won't work at all.

Here is what the help file says about DAO:

When you set a property that's defined by Microsoft Access, but applies to a DAO object, the Jet database engine doesn't automatically recognize the property as a valid property. The first time you set the property, you must create the property and append it to the Properties collection of the object to which it applies. Once the property is in the Properties collection, it can be set in the same manner as any DAO property.

I'm guessing my problem has something to do with this. Any thoughts?

Thanks,
Bill
 
Hi
This is more by way of negative information. I copied your code and built a query named as above with four fields. Then I ran your code. It worked beautifully. I added a couple more fields and changed the column widths, ran your code, perfect! Fiddled a bit more, ran your code, still great.
This might help you eliminate some possibilities...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top