reverse/mirror sorting

camaE

New member
Local time
Today, 22:06
Joined
Nov 8, 2005
Messages
5
i have a lists of emails+domain names eg camae@yahoo.com. im trying to sort them in reverse order but "reverse" seems not working in access. anyone knows how to do them or i was thinking of sorting the list begin with the domain names (which is after the '@') but i dont know how. ive tried using "like "*@[a-d]" but the result displayed is not sorted in alphabetic order. sorry im a beginner. thanks in advance
 
Use the Query Builder to experiment. It is your friend.
 
Try this on for size...

SQL:-

SELECT Right([emailAddress],Len([emailAddress])-(InStr(1,[emailAddress],"@"))) AS DomainPart, Left([emailAddress],InStr(1,[emailAddress],"@")-1) AS NamePart
FROM tblYourTableName
ORDER BY Right([emailAddress],Len([emailAddress])-(InStr(1,[emailAddress],"@"))), Left([emailAddress],InStr(1,[emailAddress],"@")-1);
 
Hi -

SELECT tblTest9.MyField
FROM tblTest9
ORDER BY ySplit([myfield],"@",False);

....with ySplit (roll-your own Split() function written in A97 but usable in later versions)
Code:
Function ySplit(ByVal pTarget As String, pItem As String, _
         Optional ShowLeft As Boolean = True) As String

'*******************************************
'Purpose:   Splits a string to the left or
'           right of pItem
'Coded by:  raskew
'Inputs:    1)  ySplit("The quick+ brown fox", "+", True)
'           2)  ysplit("The quick+ brown fox", "+", False)
'Output:    1)  The quick
'           2)  brown fox
'*******************************************

Dim strLeft  As String
Dim strRight As String
Dim n        As Integer

    n = InStr(pTarget, pItem)
    If n = 0 Then
       ySplit = ""
    Else
       ShowLeft = IIf(IsMissing(ShowLeft), True, ShowLeft)
       strLeft = Left(pTarget, n - 1)
       strRight = Mid(pTarget, n + 1)
       ySplit = Trim(IIf(ShowLeft, strLeft, strRight))
    End If
    
End Function

HTH - Bob
 
ermm..im completely lost..again, im a beginner in access and that code u gave me seems like a vb code to me (i've learn vb thou') are you suggesting me to use vb form to do the query? btw im using access 2k. thanks bob
 
Copy / paste the function into a new module.

Copy / paste the query-sql into a new query, changing the table and field name to your own.

Run the query. It should provide what you're after.

HTH - Bob
 

Users who are viewing this thread

Back
Top Bottom