Help !! My code below generates error 425 'object required'. (I'm using Access 2003)
I have a table opened as a datasheet, but the column widths need adjusting programatically to fit. I have seen posts about doing this on datasheets on forms or subforms - but can I do it this way on a table opened as a datasheet? The application is being distributed as an .mde file to general users with only custom menus showing. I can't therefore use any 'sendkeys' operation as the format menu won't be showing.
This is my code where 'tblname' is the name of the table.
...more code to identify 'td' as the targeted table (because the name might vary) and then
'tblname' is returning the correct table name and 'colname' is returning the correct fields/column names.
The error is generated at line 5 in the second section of code. I have tried variations on addressing the column width setting, all without success. What am I doing wrong?
Any ideas please
I have a table opened as a datasheet, but the column widths need adjusting programatically to fit. I have seen posts about doing this on datasheets on forms or subforms - but can I do it this way on a table opened as a datasheet? The application is being distributed as an .mde file to general users with only custom menus showing. I can't therefore use any 'sendkeys' operation as the format menu won't be showing.
This is my code where 'tblname' is the name of the table.
Code:
Dim db as DAO.Database Dim td as DAO.TableDef Dim col as DAO.Field Dim tblname, colname as String set db as CurrentDb
Code:
tblename = td.Name
DoCmd.OpenTable tblname, acViewNormal, ReadOnly
For each col in td.fields
colname = col.name
Table!tblname.Field.colname.ColumnWidth = -2
Next
The error is generated at line 5 in the second section of code. I have tried variations on addressing the column width setting, all without success. What am I doing wrong?
Any ideas please
Comment