Access 2003 Move fields on a datasheet subform...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a subform that is displayed as a datasheet. Access 97 allowed me to
move the fields around and save the position of the fields in the subform by
clicking on the save button on the toolbar. In Access 2003, I move the field
that is at the end of the view to the front, click the save button and exit.
When I enter back in the form, the field is placed back at the end. How can I
save the location of the fields in the subform? Why can I not move a field
and have Access 2003 remember where I moved it?

Thanks in advance.
 
I can't answer the 'why' of it, but here's a way to save the column
positions when the form is closed and restore them when it is opened ...

Private Sub Form_Close()

Dim ctl As Control
Dim aob As AccessObject

Set aob = CurrentProject.AllForms(Me.Name)
For Each ctl In Me.Controls

'Modify as necessary to include other types of control, e.g.
acComboBox
If ctl.ControlType = acTextBox Then
aob.Properties.Add ctl.Name, ctl.ColumnOrder
End If
Next ctl

End Sub

Private Sub Form_Open(Cancel As Integer)

Dim ctl As Control
Dim aob As AccessObject
Dim aop As AccessObjectProperty

Set aob = CurrentProject.AllForms(Me.Name)
For Each ctl In Me.Controls

'See previous comment
If ctl.ControlType = acTextBox Then

'Property won't exist first time form is opened.
Set aop = Nothing
On Error Resume Next
Set aop = aob.Properties(ctl.Name)
On Error GoTo 0
If Not aop Is Nothing Then
ctl.ColumnOrder = aop.Value
End If
End If
Next ctl

End Sub
 
Thanks for the reply and the code. It seems to me that feature should have
stayed in Access 2003. I have found a few things like this in Access 2003
(features that worked in Access 97 that do not work in Access 2003). I know
that things are going to change, but I would like an answer from Miscrosoft
(which I hope someone from the company will read this) why they took this
out.
 
Back
Top