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!

How to Prevent Moving Columns in Subform Datasheet? 1

Status
Not open for further replies.

v5652

Programmer
Mar 19, 2008
76
0
0
IN
hello friends,

I want to know that can it be possible to Prevent users Moving Columns in Subform Datasheet? (without using disable subform).

please share your ideas.
thanks.
 
This may give the effect you want.
Build the query for the subform.
Open the query in datasheet view. Select the columns and right click. Select "Freeze Columns". This property unfortunately is read only and cannot be set by code.
 
This works.
Build the subform. Add the fields to the subform in the order that you want. Set the subform to datasheet view
Code:
Public Sub setOrder()
  Dim ctl As Access.Control
  Dim intCnt As Integer
  For Each ctl In Me.Controls
    intCnt = intCnt + 1
    If ctl.controlType = acTextBox Then
      ctl.ColumnOrder = intCnt
    End If
  Next ctl
End Sub

Private Sub Form_Load()
 setOrder
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  setOrder
End Sub
 
BTW that code belongs in the subform. When you place a control on a form they are given an order in the controls collection. I do not think this order can be changed so make sure you add them in the correct order.
 
Thanks MajP.

i think it will solve my problem.

thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top