Full Version: function to sort data
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
killerwhale65
hi,

i am writing a function to sort data on a subform:
CODE
  
Public Function SortAZ()
'bepalen welke kolom focus heeft
Dim ctlCurrentControl As Control, strControlName As String
Set ctlCurrentControl = Screen.ActiveControl
strControlName = ctlCurrentControl.Name
'MsgBox strControlName
'alfabetisch sorteren volgens control die focus heeft
Me.Parent!frmSpotten.Form.OrderBy = strControlName
Me.Parent!frmSpotten.Form.OrderByOn = True
End Function


i call =SortAZ() on the doubleclick event of the control. But i'm having troubles with the last 2 lines in the function.

Also, i would like to know how i can pass the variable formname (so the name of the subformcontrol on the mainform) through with the function to be able to use the same function on different subforms. (something like =SortAZ(formname) ?)

thanks!
killerwhale65
i can get the formname via:

=SortAZ([formname])

and then:
Public Function SortAZ(formname as String)

but how should i call it then? I tried:
Forms!frmMain!formname.Form.OrderBy = strControlName & " DESC"

but that doesnt work. I guess its a matter of definition?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.