G
Guest
Hi all, (i posted this also in another form but no result...si i try again)
I have a problem with sorting records from within visual basic.
I use the On Click property of a command button:
=SortForm([Form], "[Global Title]")
etc.
with this function in a standard module:
Function SortForm(frm As Form, ByVal sOrderBy As String) As Boolean
If Len(sOrderBy) > 0 Then
' Reverse the order if already sorted this way.
If frm.OrderByOn And (frm.OrderBy = sOrderBy) Then
sOrderBy = sOrderBy & " DESC"
End If
frm.OrderBy = sOrderBy
frm.OrderByOn = True
End If
msgbox frm.OrderBy
End Function
I seems to work ok, the messagebox gives "[Global Title]" and the form sorts
ok, but it does not the second time i click on the button:
in fact the second time, it should reverse the sort order. Instead it removes
the content of the field.orderby property (the messagebox shows nothing,
empty) and displays the original records from the record source without any
sort order.
So the DESC instruction is not accepted. The third time it is fine again,
the fourth time nothing ......ectectera
Can anyone help me on this ?
I have a problem with sorting records from within visual basic.
I use the On Click property of a command button:
=SortForm([Form], "[Global Title]")
etc.
with this function in a standard module:
Function SortForm(frm As Form, ByVal sOrderBy As String) As Boolean
If Len(sOrderBy) > 0 Then
' Reverse the order if already sorted this way.
If frm.OrderByOn And (frm.OrderBy = sOrderBy) Then
sOrderBy = sOrderBy & " DESC"
End If
frm.OrderBy = sOrderBy
frm.OrderByOn = True
End If
msgbox frm.OrderBy
End Function
I seems to work ok, the messagebox gives "[Global Title]" and the form sorts
ok, but it does not the second time i click on the button:
in fact the second time, it should reverse the sort order. Instead it removes
the content of the field.orderby property (the messagebox shows nothing,
empty) and displays the original records from the record source without any
sort order.
So the DESC instruction is not accepted. The third time it is fine again,
the fourth time nothing ......ectectera
Can anyone help me on this ?