ansentry
Access amateur
- Local time
- Today, 13:41
- Joined
- Jun 1, 2003
- Messages
- 995
I would like someone to have a look at this and tell me where I have gone wrong in the second procudure.
Thank you in advance
This works fine (I download the "SampleSearch.mdb" and modified it )
Private Sub cmdSearch_Click()
On Error Resume Next
Dim sSql As String
Dim sCriteria As String
sCriteria = "WHERE 1=1 "
If Me![StartDate] <> "" And EndDate <> "" Then
sCriteria = sCriteria & " AND Qry_DeliveryDateSearch.MyDate between #" & Format(StartDate, "dd-mmm-yyyy") & "# and #" & Format(EndDate, "dd-mmm-yyyy") & "#"
End If
sSql = "SELECT DISTINCT [MyDate],[CustomerName],[Model],[SalespersonName],[ChassisNumber],[StockNum],[Colour],[Registration],[DeliveryTime],[VehiclesID] from Qry_DeliveryDateSearch " & sCriteria
Forms![Frm_DeliveryDateSearch]![frm_DeliveryDateSearchSubForm].Form.RecordSource = sSql
======SECOND PRODUCURE============
I created another form and however this one does not work, I thing it is the line,
sCriteria=sCriteria & " AND Qry_SalespersonSearch.SalespersonName"
( I just can't get my head around the different ways eg date, number or text)
Private Sub cmdSearch_Click()
Dim sSql As String
Dim sCriteria As String
sCriteria = "WHERE 1=1 "
If Me![CmboSalesperson] <> "" Then
sCriteria = sCriteria & " AND Qry_SalespersonSearch.SalespersonName"
End If
sSql = "SELECT DISTINCT [CustomerName],[Model],[MyDate],[SalespersonName],[ChassisNumber],[StockNum],[Colour],[Registration],[DeliveryTime],[VehiclesID] from Qry_SalespersonSearch " & sCriteria
Forms![Frm_SalespersonSearch]![Frm_SalespersonSearchSubForm].Form.RecordSource = sSql
End Sub
Regards,
Thank you in advance
This works fine (I download the "SampleSearch.mdb" and modified it )
Private Sub cmdSearch_Click()
On Error Resume Next
Dim sSql As String
Dim sCriteria As String
sCriteria = "WHERE 1=1 "
If Me![StartDate] <> "" And EndDate <> "" Then
sCriteria = sCriteria & " AND Qry_DeliveryDateSearch.MyDate between #" & Format(StartDate, "dd-mmm-yyyy") & "# and #" & Format(EndDate, "dd-mmm-yyyy") & "#"
End If
sSql = "SELECT DISTINCT [MyDate],[CustomerName],[Model],[SalespersonName],[ChassisNumber],[StockNum],[Colour],[Registration],[DeliveryTime],[VehiclesID] from Qry_DeliveryDateSearch " & sCriteria
Forms![Frm_DeliveryDateSearch]![frm_DeliveryDateSearchSubForm].Form.RecordSource = sSql
======SECOND PRODUCURE============
I created another form and however this one does not work, I thing it is the line,
sCriteria=sCriteria & " AND Qry_SalespersonSearch.SalespersonName"
( I just can't get my head around the different ways eg date, number or text)
Private Sub cmdSearch_Click()
Dim sSql As String
Dim sCriteria As String
sCriteria = "WHERE 1=1 "
If Me![CmboSalesperson] <> "" Then
sCriteria = sCriteria & " AND Qry_SalespersonSearch.SalespersonName"
End If
sSql = "SELECT DISTINCT [CustomerName],[Model],[MyDate],[SalespersonName],[ChassisNumber],[StockNum],[Colour],[Registration],[DeliveryTime],[VehiclesID] from Qry_SalespersonSearch " & sCriteria
Forms![Frm_SalespersonSearch]![Frm_SalespersonSearchSubForm].Form.RecordSource = sSql
End Sub
Regards,