comicwizard
Registered User.
- Local time
- Yesterday, 19:05
- Joined
- Mar 24, 2011
- Messages
- 15
Okay,
I am building a database form that uses a sub form. I got the search function to work great, had to copy some code to do so, but now I would like to have the results sorted on a different field.
the Search function uses employee id, then I am trying to add me.orderby to the code to sort by input_Dt desc.
No matter how I fiddle with the orderby I just cannot get the results to sort by input_dt desc. I have removed the me.orderby "[input_Dt] Desc" from the code because it wasn't working.
My thought was I needed to add it to the LSQL = LSQL .... part but I get an error when I do that.
Maybe I am barking up the wrong tree. :banghead:
code is as follows.
private Sub cmdSearch_Click()
Dim LSQL As String
Dim LSearchString As String
If Len(txtSearchString) = 0 Or IsNull(txtSearchString) = True Then
MsgBox "You must enter a correct Employee Number."
Else
LSearchString = txtSearchString
LSQL = "select * from Master_tbl"
LSQL = LSQL & " where Employee_ID LIKE '*" & LSearchString & "*'"
Form_Edit_Form_sub.RecordSource = LSQL
lblTitle.Caption = "Employee_ID: Filtered by '" & LSearchString & "'"
'Clear search string
txtSearchString = ""
MsgBox "Results have been filtered. All Employee_ID containing " & LSearchString & "."
End If
End Sub
I am building a database form that uses a sub form. I got the search function to work great, had to copy some code to do so, but now I would like to have the results sorted on a different field.
the Search function uses employee id, then I am trying to add me.orderby to the code to sort by input_Dt desc.
No matter how I fiddle with the orderby I just cannot get the results to sort by input_dt desc. I have removed the me.orderby "[input_Dt] Desc" from the code because it wasn't working.
My thought was I needed to add it to the LSQL = LSQL .... part but I get an error when I do that.
Maybe I am barking up the wrong tree. :banghead:
code is as follows.
private Sub cmdSearch_Click()
Dim LSQL As String
Dim LSearchString As String
If Len(txtSearchString) = 0 Or IsNull(txtSearchString) = True Then
MsgBox "You must enter a correct Employee Number."
Else
LSearchString = txtSearchString
LSQL = "select * from Master_tbl"
LSQL = LSQL & " where Employee_ID LIKE '*" & LSearchString & "*'"
Form_Edit_Form_sub.RecordSource = LSQL
lblTitle.Caption = "Employee_ID: Filtered by '" & LSearchString & "'"
'Clear search string
txtSearchString = ""
MsgBox "Results have been filtered. All Employee_ID containing " & LSearchString & "."
End If
End Sub