![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Dear All, I am using the following query for retrieving data between customer code SELECT tblOrders.CustomerCode, [tblOrder Details].InventoryCode, tblInventory.InventoryName, [tblOrder Details].Quantity FROM tblOrders INNER JOIN (tblInventory INNER JOIN [tblOrder Details] ON tblInventory.InventoryCode = [tblOrder Details].InventoryCode) ON tblOrders.OrderID = [tblOrder Details].OrderID WHERE (((tblOrders.CustomerCode) Between [Forms]![frmFilter3]![CboCustFrom] And [Forms]![frmFilter3]![CboCustTo])); how could I retrive all records if the parameter leaved blank, kindly note that the customer field is a text field with field size of 6, customer code is mixture of letter & digits & it also could be all letter or all digits Thanks & Regards, -- Abdul Shakeel |
|
SELECT tblOrders.CustomerCode, [tblOrder Details].InventoryCode, tblInventory.InventoryName, [tblOrder Details].Quantity FROM tblOrders INNER JOIN (tblInventory INNER JOIN [tblOrder Details] ON tblInventory.InventoryCode = [tblOrder Details].InventoryCode) ON tblOrders.OrderID = [tblOrder Details].OrderID |
#3
| |||
| |||
|
|
On 10/11/2010 12:36:43, Shakeel wrote: Dear All, I am using the following query for retrieving data between customer code SELECT tblOrders.CustomerCode, [tblOrder Details].InventoryCode, tblInventory.InventoryName, [tblOrder Details].Quantity FROM tblOrders INNER JOIN (tblInventory INNER JOIN [tblOrder Details] ON tblInventory.InventoryCode = [tblOrder Details].InventoryCode) ON tblOrders.OrderID = [tblOrder Details].OrderID WHERE (((tblOrders.CustomerCode) Between [Forms]![frmFilter3]![CboCustFrom] And [Forms]![frmFilter3]![CboCustTo])); how could I retrive all records if the parameter leaved blank, kindly note that the customer field is a text field with field size of 6, customer code is mixture of letter & digits & it also could be all letter or all digits Thanks & Regards, -- Abdul Shakeel This is a bit complex. If you change the query for your combo boxes which I assume is something like "SELECT CustomerName, CustomerCode FROM Customers ORDER by CustomerName" to a Union Query "SELECT CustomerName, CustomerCode, 1 AS Pos FROM Customers UNION SELECT 'B.O.F.' AS CustomerName, ' ' AS CustomerCode, 0 AS Pos ORDER BY Pos, CustomerName;" This should have the first entry in the CboCustFrom box "B.O.F" - begining of file. You need a similar set up for your CboCustTo box showing "E.O.F." - End of file |
#4
| |||
| |||
|
|
On 10/11/2010 15:24:46, "Phil" wrote: On 10/11/2010 12:36:43, Shakeel wrote: Dear All, I am using the following query for retrieving data between customer code SELECT tblOrders.CustomerCode, [tblOrder Details].InventoryCode, tblInventory.InventoryName, [tblOrder Details].Quantity FROM tblOrders INNER JOIN (tblInventory INNER JOIN [tblOrder Details] ON tblInventory.InventoryCode = [tblOrder Details].InventoryCode) ON tblOrders.OrderID = [tblOrder Details].OrderID WHERE (((tblOrders.CustomerCode) Between [Forms]![frmFilter3]![CboCustFrom] And [Forms]![frmFilter3]![CboCustTo])); how could I retrive all records if the parameter leaved blank, kindly note that the customer field is a text field with field size of 6, customer code is mixture of letter & digits & it also could be all letter or all digits Thanks & Regards, -- Abdul Shakeel This is a bit complex. If you change the query for your combo boxes which I assume is something like "SELECT CustomerName, CustomerCode FROM Customers ORDER by CustomerName" to a Union Query "SELECT CustomerName, CustomerCode, 1 AS Pos FROM Customers UNION SELECT 'B.O.F.' AS CustomerName, ' ' AS CustomerCode, 0 AS Pos ORDER BY Pos, CustomerName;" This should have the first entry in the CboCustFrom box "B.O.F" - begining of file. You need a similar set up for your CboCustTo box showing "E.O.F." - End of file Sorry this News server seems to send meggages whether they are complete or not. To continue You then need to build the SQL SQLStg = "SELECT tblOrders.CustomerCode, [tblOrder Details].InventoryCode, " SQLStg = SQLStg & "tblInventory.InventoryName, [tblOrder Details].Quantity FROM tblOrders " SQLStg = SQLStg & "INNER JOIN (tblInventory INNER JOIN [tblOrder Details] ON " SQLStg = SQLStg & "tblInventory.InventoryCode [tblOrder Details].InventoryCode) ON " SQLStg = SQLStg & "tblOrders.OrderID [tblOrder Details].OrderID " |
#5
| |||
| |||
|
|
On 10/11/2010 15:32:15, "Phil" wrote: On 10/11/2010 15:24:46, "Phil" wrote: On 10/11/2010 12:36:43, Shakeel wrote: Dear All, I am using the following query for retrieving data between customer code SELECT tblOrders.CustomerCode, [tblOrder Details].InventoryCode, tblInventory.InventoryName, [tblOrder Details].Quantity FROM tblOrders INNER JOIN (tblInventory INNER JOIN [tblOrder Details] ON tblInventory.InventoryCode = [tblOrder Details].InventoryCode) ON tblOrders.OrderID = [tblOrder Details].OrderID WHERE (((tblOrders.CustomerCode) Between [Forms]![frmFilter3]![CboCustFrom] And [Forms]![frmFilter3]![CboCustTo])); how could I retrive all records if the parameter leaved blank, kindly note that the customer field is a text field with field size of 6, customer code is mixture of letter & digits & it also could be all letter or all digits Thanks & Regards, -- Abdul Shakeel This is a bit complex. If you change the query for your combo boxes which I assume is something like "SELECT CustomerName, CustomerCode FROM Customers ORDER by CustomerName" to a Union Query "SELECT CustomerName, CustomerCode, 1 AS Pos FROM Customers UNION SELECT 'B.O.F.' AS CustomerName, ' ' AS CustomerCode, 0 AS Pos ORDER BY Pos, CustomerName;" This should have the first entry in the CboCustFrom box "B.O.F" - begining of file. You need a similar set up for your CboCustTo box showing "E.O.F." - End of file Sorry this News server seems to send meggages whether they are completeor not. To continue You then need to build the SQL SQLStg = "SELECT tblOrders.CustomerCode, [tblOrder Details].InventoryCode, " SQLStg = SQLStg & "tblInventory.InventoryName, [tblOrder Details].Quantity FROM tblOrders " SQLStg = SQLStg & "INNER JOIN (tblInventory INNER JOIN [tblOrder Details] ON " SQLStg = SQLStg & "tblInventory.InventoryCode [tblOrder Details].InventoryCode) ON " SQLStg = SQLStg & "tblOrders.OrderID [tblOrder Details].OrderID " Sorry it's sent it again The last bit should read If CboCustFrom <> "B.O.F." then SQLStg LStg = SQLStg & "WHERE tblOrders.CustomerCode >= [Forms]![frmFilter3]![CboCustFrom] End If If CboCustTo <> "E.O.F." then * * If CboCustFrom <> "B.O.F." then SQLStg SQLStg = SQLStg & "AND tblOrders.CustomerCode >= [Forms]![frmFilter3]![CboCustTo] * *Else SQLStg SQLStg = SQLStg & "WHERE tblOrders.CustomerCode <= [Forms]![frmFilter3]![CboCustTo] * *End If End If Finally got there. Hope you can make sense of these bits Phil |
#6
| |||
| |||
|
|
On 10/11/2010 15:32:15, "Phil" wrote: On 10/11/2010 15:24:46, "Phil" wrote: On 10/11/2010 12:36:43, Shakeel wrote: Dear All, I am using the following query for retrieving data between customer code SELECT tblOrders.CustomerCode, [tblOrder Details].InventoryCode, tblInventory.InventoryName, [tblOrder Details].Quantity FROM tblOrders INNER JOIN (tblInventory INNER JOIN [tblOrder Details] ON tblInventory.InventoryCode = [tblOrder Details].InventoryCode) ON tblOrders.OrderID = [tblOrder Details].OrderID WHERE (((tblOrders.CustomerCode) Between [Forms]![frmFilter3]![CboCustFrom] And [Forms]![frmFilter3]![CboCustTo])); how could I retrive all records if the parameter leaved blank, kindly note that the customer field is a text field with field size of 6, customer code is mixture of letter & digits & it also could be all letter or all digits Thanks & Regards, -- Abdul Shakeel This is a bit complex. If you change the query for your combo boxes which I assume is something like "SELECT CustomerName, CustomerCode FROM Customers ORDER by CustomerName" to a Union Query "SELECT CustomerName, CustomerCode, 1 AS Pos FROM Customers UNION SELECT 'B.O.F.' AS CustomerName, ' ' AS CustomerCode, 0 AS Pos ORDER BY Pos, CustomerName;" This should have the first entry in the CboCustFrom box "B.O.F" - begining of file. You need a similar set up for your CboCustTo box showing "E.O.F." - End of file Sorry this News server seems to send meggages whether they are complete or not. To continue You then need to build the SQL SQLStg = "SELECT tblOrders.CustomerCode, [tblOrder Details].InventoryCode, " SQLStg = SQLStg & "tblInventory.InventoryName, [tblOrder Details].Quantity FROM tblOrders " SQLStg = SQLStg & "INNER JOIN (tblInventory INNER JOIN [tblOrder Details] ON " SQLStg = SQLStg & "tblInventory.InventoryCode [tblOrder Details].InventoryCode) ON " SQLStg = SQLStg & "tblOrders.OrderID [tblOrder Details].OrderID " Sorry it's sent it again The last bit should read If CboCustFrom <> "B.O.F." then SQLStg LStg = SQLStg & "WHERE tblOrders.CustomerCode >= [Forms]![frmFilter3]![CboCustFrom] End If If CboCustTo <> "E.O.F." then If CboCustFrom <> "B.O.F." then SQLStg SQLStg = SQLStg & "AND tblOrders.CustomerCode >= [Forms]![frmFilter3]![CboCustTo] Else SQLStg SQLStg = SQLStg & "WHERE tblOrders.CustomerCode <= [Forms]![frmFilter3]![CboCustTo] End If End If Finally got there. Hope you can make sense of these bits Phil |
![]() |
| Thread Tools | |
| Display Modes | |
| |