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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Controlling datasheet properties in code 1

Status
Not open for further replies.

flize

IS-IT--Management
Jun 23, 2003
14
0
0
US
When I view a datasheet as a subform from a main form, I can resize the width and reorder the columns on the grid display, then select SAVE from the File menu to save those settings.

How can I update or access these settings in code?

When I view the individual fields on the subform in design mode, they don't correspond to their position/size on the grid when viewed(opened). So, I'm wondering where/how Access saves the settings from the datasheet grid view.

Thanks, flize
 
it comes from the tables columnwidth property. See columnwidth in access help

You can use the ColumnWidth property to specify the width of a column in Datasheet view.

Note The ColumnWidth property applies to all fields in Datasheet view and to form controls when the form is in Datasheet view.
 
Thanks gol4, thats a step in the right direction.

But my problem is that I don't use a table or predefined query as the datasource.

The datasheet's record source is based on a dynamic SQL string stored in a variable (SQLvar) that is created by various user selections. I set it dynamically in the subform's ON_OPEN event (RecordSource = SQLvar).

So, if the form has no permanent table or query, where are the grid settings being saved? It has to be in the subform somewhere, no?

Also, I need to set the column positions (right to left) thru code as well.




 
can you just run thru the controls collection

Me![SubFRM].Form.Controls(0).ColumnWidth = 130

 
forgot to address colunmnorder. would be same as columnwidth

Me![SubFRM].Form.Controls(0).ColumnOrder = 2
 
Yes, I got it now!

When you mentioned the tables properties, that threw me off. So, I just needed to reference the control's columnsize and columnwidth properties ( as well as columnhidden)...works great.

Thanks again!
flize
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top