DrillMonkey
Technical User
Hi,
I am using a form with a combo box and a text box to accept a string to search 2 tables. I recive the following error
********************************
run-time error 3138
Syntax error in ORDER BY clause.
********************************
Row source type: Field List
Row source: see code
I think I am missing a ORDER BY Clause but am not sure which part of the row source it goes..Thank you
I am using a form with a combo box and a text box to accept a string to search 2 tables. I recive the following error
********************************
run-time error 3138
Syntax error in ORDER BY clause.
********************************
Row source type: Field List
Row source: see code
Code:
SELECT [tblWarehouse].[Date], [tblWarehouse].[Signature], [tblWarehouse].[Driver], [tblPurchData].[Purchase Order], [tblPurchData].[Requisition], [tblPurchData].[Stores Order], [tblPurchData].[Ticket], [tblPurchData].[Memo Number], [tblPurchData].[Discription], [tblPurchData].[Parcels] FROM tblWarehouse INNER JOIN tblPurchData ON [tblWarehouse].[WarehouseID]=[tblPurchData].[WarehouseID];
Code:
Private Sub cmdSearch_Click()
If Len(cboSearchField) = 0 Or IsNull(cboSearchField) = True Then
MsgBox "You must select a field to search."
ElseIf Len(txtSearchString) = 0 Or IsNull(txtSearchString) = True Then
MsgBox "You must enter a search string."
Else
'Generate search criteria
GCriteria = cboSearchField.Value & " LIKE '*" & txtSearchString & "*'"
'Filter Form1 based on search criteria
Form_ListFrm.RecordSource = "select * from tblWarehouse where " & GCriteria
'Form_ListFrm.Caption = "tblWarehouse (" & cboSearchField.Value & " contains '*" & txtSearchString & "*')"
'Close frmSearch
DoCmd.Close acForm, "frmSearch"
'Open report
DoCmd.OpenReport "rptWarehouse", acViewPreview, , GCriteria
DoCmd.Maximize
'MsgBox "Results have been filtered."
End If
End Sub