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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command button to sort using "Tag" property. Tough one??? Help ASAP!

Status
Not open for further replies.
Jan 22, 2001
124
US
Hi

Here is the function:

Public Function SortByTag(ctlCurrent As Control, frmCurrent As Form)

Dim SortOrd, FormName As String
SortOrd = ctlCurrent.Tag

If ctlCurrent.Tag = frmCurrent.OrderBy Then
frmCurrent.OrderBy = SortOrd & " DESC"
frmCurrent.OrderByOn = True
Else
frmCurrent.OrderBy = SortOrd
frmCurrent.OrderByOn = True
End If

End Function


Here is the Control Source of the field (Complete Date) attempted to be sorted:

=Nz(DLookUp("CompletionDate","CompletionInfo","RequestID= " & [Forms]![LookupReqFRM]![LookupRequests subform]![RequestID]))

The name of the command button to sort this field is "Complete Date". Here is the "On Click" expression:

=SortByTag([Complete Date],[Forms]![LookupReqFRM]![LookupRequests subform].[Form])

My question is, what should I set the "Tag" property to for this command button to work properly? The other (working) command buttons that perform this function use the "Control Source" of the field being sorted in it's "Tag" property.

Because the "Control Source" for this field is unusual, I cannot get the sort to work. Any ideas?
 
The Order By property of your form needs the names of one or more fields in the underlying Recordset to which the form is bound. Your [Complete Date] control does not appear to be Bound to any Recordset field. So, you cannot directly reorder the Recordset by the [Complete Date] field.

If you have another control on your form that is Bound to a field in the underlying Recordset on which you can actually sort, then you would put the name of that field in the Tag property of the [Complete Date] control. For example, if you have a Bound control named [Request Date], then you would put that field's name, [Request Date], in the Tag property of the [Complete Date] control.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top