Folks



I'm glad to say my database is now up and running, with the help of this website. But I have a new problem!

I have a main form that opens in datasheet view and, within it, a subform that opens as a subdatasheet. My switchboard contains a button that opens the main form, and its On Click event contains the following code:

Code:
 
Forms!MainForm!Field1.ColumnWidth = -2
Forms!MainForm!Field2.ColumnWidth = -2
Forms!MainForm!Field3.ColumnWidth = -2
This ensures that all the columns in the main form are sized to fit their contents.

However, I'd like all the columns in the subform also to be sized to fit their contents. So I've tried this:

Code:
 
Forms!MainForm!Subform.Form!Field1.ColumnWidth = -2
But when I click on the button I get the message "You entered an expression that has an invalid reference to the property Form/Report".

If I set the main form's Subdatasheet Expanded property to Yes, I no longer get the message, and the columns are sized to fit their contents, but only for the contents of the subdatasheet records for Field1 of the main form!

So what do I need to do get my subform to open with all its columns sized to fit their contents? Is there some way to select all subdatasheet records before setting the column widths? Or is there an event that fires on clicking the "+" sign to expand the subdatasheet?

Many thanks

Remster