Disable sorting on subforms

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

Guest

How do I disable someones ability to sort or filter on data in a subform?
It appears that when someone attempts to sort or apply a filter to a subform,
the subform goes blank and cannot be restored until I open the subform
properties and delete the 'filter' or 'order by' text.
 
There is a form property (Data tab) called AllowFilters. Set it to No on your
subform.

Barry
 
Barry,

I set AllowFilters to NO. While this did disable the 'Filter By Selection'
button, it did not disable someones ability to sort the subform. When the
subform is sorted, the field ID appears in the Order By section of the
properties for the subform. When the form is closed and reopened, the
subform is completey blank (solid white). When I enter the properties for
the subform and clear the Order By value, the subform reappears. HOW DO I
disable the ability to sort a subform?
 
Try in the OnOpen event of the parent form


me.[subformname].orderbyon = false
me.[subformname].orderby = null

You could do the same thing with the filterby so the user could use it
but as soon as they got out of the mainform, it would be reset.

You may have to play with the addressing to get the the property.
 
Thanks Barry... I tried the following code and got a compiler error (Method
or data Member not found). I verified the spelling of both the sub form and
the main form. Am I missing something here?

Private Sub Form_Open(Cancel As Integer)
Me.FSinvxSUB1.FMinvxMAIN.OrderByOn = False
Me.FSinvxSUB1.FMinvxMAIN.OrderBy = Null
End Sub

Barry Gilbert said:
Me.SubFormName.Form.OrderByOn = False
Me.SubFormName.Form.OrderBy = False

Ron2006 said:
Try in the OnOpen event of the parent form


me.[subformname].orderbyon = false
me.[subformname].orderby = null

You could do the same thing with the filterby so the user could use it
but as soon as they got out of the mainform, it would be reset.

You may have to play with the addressing to get the the property.
 
Try:
Private Sub Form_Open(Cancel As Integer)
Me.FSinvxSUB1.Form.OrderByOn = False
Me.FSinvxSUB1.Form.OrderBy = Null
End Sub

Look in the help files for how to reference subforms. In your statement, I
assume that FXinvxSub1 is the name of the subform. It's important that this
refer to the name of the subform CONTROL, not the name of the form. By
default, these are the same, but not necessarily.

Barry



Ernie Sersen said:
Thanks Barry... I tried the following code and got a compiler error (Method
or data Member not found). I verified the spelling of both the sub form and
the main form. Am I missing something here?

Private Sub Form_Open(Cancel As Integer)
Me.FSinvxSUB1.FMinvxMAIN.OrderByOn = False
Me.FSinvxSUB1.FMinvxMAIN.OrderBy = Null
End Sub

Barry Gilbert said:
Me.SubFormName.Form.OrderByOn = False
Me.SubFormName.Form.OrderBy = False

Ron2006 said:
Try in the OnOpen event of the parent form


me.[subformname].orderbyon = false
me.[subformname].orderby = null

You could do the same thing with the filterby so the user could use it
but as soon as they got out of the mainform, it would be reset.

You may have to play with the addressing to get the the property.
 
Try:
Private Sub Form_Open(Cancel As Integer)
Me.FSinvxSUB1.Form.OrderByOn = False
Me.FSinvxSUB1.Form.OrderBy = Null
End Sub

Look in the help files for how to reference subforms. In your statement, I
assume that FXinvxSub1 is the name of the subform. It's important that this
refer to the name of the subform CONTROL, not the name of the form. By
default, these are the same, but not necessarily.

Barry



Ernie Sersen said:
Thanks Barry... I tried the following code and got a compiler error (Method
or data Member not found). I verified the spelling of both the sub form and
the main form. Am I missing something here?

Private Sub Form_Open(Cancel As Integer)
Me.FSinvxSUB1.FMinvxMAIN.OrderByOn = False
Me.FSinvxSUB1.FMinvxMAIN.OrderBy = Null
End Sub

Barry Gilbert said:
Me.SubFormName.Form.OrderByOn = False
Me.SubFormName.Form.OrderBy = False

Ron2006 said:
Try in the OnOpen event of the parent form


me.[subformname].orderbyon = false
me.[subformname].orderby = null

You could do the same thing with the filterby so the user could use it
but as soon as they got out of the mainform, it would be reset.

You may have to play with the addressing to get the the property.
 
Gettin closer. I now get an Error Message #94: Invalid use of NULL. Both
the name and source object are the same: FSinvxSUB1.

Barry Gilbert said:
Try:
Private Sub Form_Open(Cancel As Integer)
Me.FSinvxSUB1.Form.OrderByOn = False
Me.FSinvxSUB1.Form.OrderBy = Null
End Sub

Look in the help files for how to reference subforms. In your statement, I
assume that FXinvxSub1 is the name of the subform. It's important that this
refer to the name of the subform CONTROL, not the name of the form. By
default, these are the same, but not necessarily.

Barry



Ernie Sersen said:
Thanks Barry... I tried the following code and got a compiler error (Method
or data Member not found). I verified the spelling of both the sub form and
the main form. Am I missing something here?

Private Sub Form_Open(Cancel As Integer)
Me.FSinvxSUB1.FMinvxMAIN.OrderByOn = False
Me.FSinvxSUB1.FMinvxMAIN.OrderBy = Null
End Sub

Barry Gilbert said:
Me.SubFormName.Form.OrderByOn = False
Me.SubFormName.Form.OrderBy = False

:

Try in the OnOpen event of the parent form


me.[subformname].orderbyon = false
me.[subformname].orderby = null

You could do the same thing with the filterby so the user could use it
but as soon as they got out of the mainform, it would be reset.

You may have to play with the addressing to get the the property.
 
Ah. I didn't catch this the first time. The OrderBy property accepts strings
only. Try:
Me.FSinvxSUB1.Form.OrderBy = ""

Barry

Ernie Sersen said:
Gettin closer. I now get an Error Message #94: Invalid use of NULL. Both
the name and source object are the same: FSinvxSUB1.

Barry Gilbert said:
Try:
Private Sub Form_Open(Cancel As Integer)
Me.FSinvxSUB1.Form.OrderByOn = False
Me.FSinvxSUB1.Form.OrderBy = Null
End Sub

Look in the help files for how to reference subforms. In your statement, I
assume that FXinvxSub1 is the name of the subform. It's important that this
refer to the name of the subform CONTROL, not the name of the form. By
default, these are the same, but not necessarily.

Barry



Ernie Sersen said:
Thanks Barry... I tried the following code and got a compiler error (Method
or data Member not found). I verified the spelling of both the sub form and
the main form. Am I missing something here?

Private Sub Form_Open(Cancel As Integer)
Me.FSinvxSUB1.FMinvxMAIN.OrderByOn = False
Me.FSinvxSUB1.FMinvxMAIN.OrderBy = Null
End Sub

:

Me.SubFormName.Form.OrderByOn = False
Me.SubFormName.Form.OrderBy = False

:

Try in the OnOpen event of the parent form


me.[subformname].orderbyon = false
me.[subformname].orderby = null

You could do the same thing with the filterby so the user could use it
but as soon as they got out of the mainform, it would be reset.

You may have to play with the addressing to get the the property.
 
Great job! This works fine. Although I am still able to sort the subform,
it no longer blanks out the subform when exiting and re-entering the main
form. The sort order of the subform is also returned to its original order.
Actually, this solution is better than the one that I envisioned. Thanks for
the help!

Barry Gilbert said:
Ah. I didn't catch this the first time. The OrderBy property accepts strings
only. Try:
Me.FSinvxSUB1.Form.OrderBy = ""

Barry

Ernie Sersen said:
Gettin closer. I now get an Error Message #94: Invalid use of NULL. Both
the name and source object are the same: FSinvxSUB1.

Barry Gilbert said:
Try:
Private Sub Form_Open(Cancel As Integer)
Me.FSinvxSUB1.Form.OrderByOn = False
Me.FSinvxSUB1.Form.OrderBy = Null
End Sub

Look in the help files for how to reference subforms. In your statement, I
assume that FXinvxSub1 is the name of the subform. It's important that this
refer to the name of the subform CONTROL, not the name of the form. By
default, these are the same, but not necessarily.

Barry



:

Thanks Barry... I tried the following code and got a compiler error (Method
or data Member not found). I verified the spelling of both the sub form and
the main form. Am I missing something here?

Private Sub Form_Open(Cancel As Integer)
Me.FSinvxSUB1.FMinvxMAIN.OrderByOn = False
Me.FSinvxSUB1.FMinvxMAIN.OrderBy = Null
End Sub

:

Me.SubFormName.Form.OrderByOn = False
Me.SubFormName.Form.OrderBy = False

:

Try in the OnOpen event of the parent form


me.[subformname].orderbyon = false
me.[subformname].orderby = null

You could do the same thing with the filterby so the user could use it
but as soon as they got out of the mainform, it would be reset.

You may have to play with the addressing to get the the property.
 
Back
Top