Finding width of field in query programmatically

  • Thread starter Thread starter Ed Ferrero
  • Start date Start date
E

Ed Ferrero

If I open a query in Access, I can click on a coulmn and use the menu item
'Format --> Column Width' to obtain a value for the width of the column as
displayed in the datasheet view.

How can I get this value using VBA?

Ed Ferrero
Microsoft Excel MVP
http://www.edferrero.com
 
These lines are a bit long and may get broken in the newsgroup post, so
watch out for that ...

Public Function QueryColumnWidth(ByVal QueryName As String, ByVal ColumnName
As String) As Long

QueryColumnWidth =
CurrentDb.QueryDefs(QueryName).Fields(ColumnName).Properties("ColumnWidth")

End Function

Example of use, in Immediate Window ...

? QueryColumnWidth("qryTest", "TestDate")
2565
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top