Derek Brown
asked on
OrderBy
What is the correct expression for a command button in the form header on a continuous subform ("SetsSubForm") to order the records by IDNumber (which is a Text field if it is relevant)
Code behind your command button:
Me.OrderBy ="[IDNumber]" ' OR Me.OrderBy= "IDNumber"
Me.OrderByOn = True
Descending
Me.OrderBy ="[IDNumber] DESC" ' OR Me.OrderBy= "IDNumber DESC"
Me.OrderBy ="[IDNumber]" ' OR Me.OrderBy= "IDNumber"
Me.OrderByOn = True
Descending
Me.OrderBy ="[IDNumber] DESC" ' OR Me.OrderBy= "IDNumber DESC"
if that is a subform, try
me![subformcontrolName].or derby="[ID Number]"
for descending
me![subformcontrolName].or derby="[ID Number] Desc"
me![subformcontrolName].or derbyon=tr ue
or
me![subformcontrolName].Fo rm.orderby ="[IDNumbe r]"
for descending
me![subformcontrolName].Fo rm.orderby ="[IDNumbe r] Desc"
me![subformcontrolName].Fo rm.orderby on=true
me![subformcontrolName].or
for descending
me![subformcontrolName].or
me![subformcontrolName].or
or
me![subformcontrolName].Fo
for descending
me![subformcontrolName].Fo
me![subformcontrolName].Fo
ASKER
Thanks Hnasr
Don't really know if I should post this here but previous thread a week ago has closed.
In a in a procedure that runs from the attached continuous form. I'm using
Me.RecordSource = "Select * from SetsQuery Order By Val(TrimNumString([DoorNum ber]))"
Where setsQuery is the forms record source
I copied a function from another thread earlier
I get out of stack space.
What am I doing wrong?
Public Function TrimNumString( _
ByVal strNumString As String, _
Optional ByVal strDecimalChr As String, _
Optional ByVal booAcceptMinus As Boolean) _
As String
' Removes any non-numeric character from strNumString including hexadecimal characters.
' If strDecimalChr is specified, first occurrence of this is not removed.
' If booAcceptMinus is True, a leading or trailing minus sign is accepted.
'
' 1999-08-27. Cactus Data ApS, CPH.
' 2001-06-21. Speed optimized for large string (64 K).
' 2003-12-10. intOffset changed to lngOffset.
Const cbytNeg As Byte = 45 ' "-"
Dim lngPos As Long
Dim lngLen As Long
Dim lngOffset As Long
Dim booDec As Boolean
Dim booNeg As Boolean
Dim bytChr As Byte
Dim bytDec As Byte
Dim strNum As String
strNumString = Trim(strNumString)
lngLen = Len(strNumString)
If lngLen > 0 Then
If Len(strDecimalChr) > 0 Then
bytDec = Asc(strDecimalChr)
End If
' Create empty result string of maximum possible length.
strNum = Space(lngLen)
For lngPos = 1 To lngLen
bytChr = Asc(Mid(strNumString, lngPos, 1))
Select Case bytChr
Case 48 To 57
' Digit.
Case bytDec
' Decimal point.
If booDec = False Then
' One decimal point only.
booDec = True
End If
Case cbytNeg
' Minus sign.
bytChr = 0
If booAcceptMinus = True And booNeg = False Then
If Len(Trim(strNum)) = 0 Or lngPos = lngLen Then
bytChr = cbytNeg
' One minus sign only.
booNeg = True
End If
End If
Case Else
' Ignore any other character.
bytChr = 0
End Select
If bytChr > 0 Then
' Append accepted character by inserting it in result string.
lngOffset = lngOffset + 1
Mid(strNum, lngOffset) = Chr(bytChr)
End If
Next
End If
' Trim and return result string.
TrimNumString Left(strNum, lngOffset)
End Function
Don't really know if I should post this here but previous thread a week ago has closed.
In a in a procedure that runs from the attached continuous form. I'm using
Me.RecordSource = "Select * from SetsQuery Order By Val(TrimNumString([DoorNum
Where setsQuery is the forms record source
I copied a function from another thread earlier
I get out of stack space.
What am I doing wrong?
Public Function TrimNumString( _
ByVal strNumString As String, _
Optional ByVal strDecimalChr As String, _
Optional ByVal booAcceptMinus As Boolean) _
As String
' Removes any non-numeric character from strNumString including hexadecimal characters.
' If strDecimalChr is specified, first occurrence of this is not removed.
' If booAcceptMinus is True, a leading or trailing minus sign is accepted.
'
' 1999-08-27. Cactus Data ApS, CPH.
' 2001-06-21. Speed optimized for large string (64 K).
' 2003-12-10. intOffset changed to lngOffset.
Const cbytNeg As Byte = 45 ' "-"
Dim lngPos As Long
Dim lngLen As Long
Dim lngOffset As Long
Dim booDec As Boolean
Dim booNeg As Boolean
Dim bytChr As Byte
Dim bytDec As Byte
Dim strNum As String
strNumString = Trim(strNumString)
lngLen = Len(strNumString)
If lngLen > 0 Then
If Len(strDecimalChr) > 0 Then
bytDec = Asc(strDecimalChr)
End If
' Create empty result string of maximum possible length.
strNum = Space(lngLen)
For lngPos = 1 To lngLen
bytChr = Asc(Mid(strNumString, lngPos, 1))
Select Case bytChr
Case 48 To 57
' Digit.
Case bytDec
' Decimal point.
If booDec = False Then
' One decimal point only.
booDec = True
End If
Case cbytNeg
' Minus sign.
bytChr = 0
If booAcceptMinus = True And booNeg = False Then
If Len(Trim(strNum)) = 0 Or lngPos = lngLen Then
bytChr = cbytNeg
' One minus sign only.
booNeg = True
End If
End If
Case Else
' Ignore any other character.
bytChr = 0
End Select
If bytChr > 0 Then
' Append accepted character by inserting it in result string.
lngOffset = lngOffset + 1
Mid(strNum, lngOffset) = Chr(bytChr)
End If
Next
End If
' Trim and return result string.
TrimNumString Left(strNum, lngOffset)
End Function
ASKER
Thanks Ray
Do I need the brackets around "[DoorNumber]"
Do I need the brackets around "[DoorNumber]"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great thanks
Welcome!
Me.RecordSource = "Select * from tbl Order BY ID Desc"
Me.Refresh
modify tbl, ID, Desc as needed.
Default is ascending.