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
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