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 Westi 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". Inherited dbase. PLEASE HELP!!!

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?

 
I think you would set it to the ControlSource property as usual, except omit the leading "=".

Rick Sprague
 
"It doesn't work" doesn't give me anything to go on. Did you get some kind of message? Rick Sprague
 
[bugeyed] You can't sort a recordset that doesn't include the sort field (CompetionDate) in its recordsource, which is surely why you're using a DLookup to get at the field.

The Tag property has to refer to a valid field name in the underlying recordset, not a lookup value.

You may want to build a query for the form's recordsource that includes the date field so you can sort with it.
VBSlammer
redinvader3walking.gif

Unemployed in Houston, Texas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top