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!

DATASHEET COLUMNS

Status
Not open for further replies.

newfrontiers

Programmer
Oct 17, 2001
134
0
0
US
Does anyone know how to prohibit a user from changing the column width of a datasheet form? If so, I would greatly appreciate some guidance.

Regards.
 
Hi,

I just had a go at this and came up with a form (displaying in datasheet view) with 5 fields each of which has the following vb on the Enter() event:

Private Sub Field1_Enter()
Field1.ColumnWidth = 500
Field2.ColumnWidth = 500
Field3.ColumnWidth = 500
Field4.ColumnWidth = 500
Field5.ColumnWidth = 500
End Sub

Private Sub Field2_Enter()
Field1.ColumnWidth = 500
Field2.ColumnWidth = 500
Field3.ColumnWidth = 500
Field4.ColumnWidth = 500
Field5.ColumnWidth = 500
End Sub

Private Sub Field3_Enter()
Field1.ColumnWidth = 500
Field2.ColumnWidth = 500
Field3.ColumnWidth = 500
Field4.ColumnWidth = 500
Field5.ColumnWidth = 500
End Sub

Private Sub Field4_Enter()
Field1.ColumnWidth = 500
Field2.ColumnWidth = 500
Field3.ColumnWidth = 500
Field4.ColumnWidth = 500
Field5.ColumnWidth = 500
End Sub

Private Sub Field5_Enter()
Field1.ColumnWidth = 500
Field2.ColumnWidth = 500
Field3.ColumnWidth = 500
Field4.ColumnWidth = 500
Field5.ColumnWidth = 500
End Sub

It does'nt exactly lock the columns, ie the user can make a column adjustment, but as soon as focus returns to anywhere on the datasheet (either another field in the same record or another record) the columns are all reset again.

John Davy-Bowker
www.dbLetterWriter.com
 
newfrontiers:
I know that this does'nt really answer your question, but why not let the user change the column widths, but force the form to always open with defined widths settings by putting code, similar to that supplied by the above post, in the OnOpen event of the form.

jobo123:
John, why not create just a single routine with your above code, then call it for each of the enter events; eg.

Private Sub AnyFieldEnter ()
Field1.ColumnWidth = 500
Field2.ColumnWidth = 500
Field3.ColumnWidth = 500
Field4.ColumnWidth = 500
Field5.ColumnWidth = 500
End Sub

Then, the OnEnter events become:

Private Sub Field1_Enter()
AnyFieldEnter
End Sub

Private Sub Field2_Enter()
AnyFieldEnter
End Sub

and so on.



Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
(dont cut corners or you'll go round in circles)
 
Thank you for both of your input. I am going to play around with the columnwidth commands you reference. I think I will lean towards configuring during the On Open event.

Thanks again.

John Poppe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top