SteveL13
asked on
How display part of a field in a combobox
I have a field in a combobox that looks like:
Applesauce, 19x25, Green, Vertical, Chicago
But I want it to display everything up to the last comma like:
Applesauce, 19x25, Green, Vertical
In other words don't display the ", Chicago" part of it.
How can I do this?
--Steve
Applesauce, 19x25, Green, Vertical, Chicago
But I want it to display everything up to the last comma like:
Applesauce, 19x25, Green, Vertical
In other words don't display the ", Chicago" part of it.
How can I do this?
--Steve
what is the rowSource of the combo box?
ASKER
Here is the SQL of the query:
SELECT tblProducts.ProductID, tblProducts.ProdRef, tblLocations.LocationDesc, Sum([IncomingQty]-[SoldQty ]) AS [Inv Qty]
FROM (tblProducts LEFT JOIN tblLocations ON tblProducts.LocationID = tblLocations.LocationID) RIGHT JOIN tblInventoryDetails ON tblProducts.ProductID = tblInventoryDetails.Produc tID
GROUP BY tblProducts.ProductID, tblProducts.ProdRef, tblLocations.LocationDesc
HAVING (((tblProducts.ProdRef) Like "*" & [Forms]![frmSearchForProdu ctsOrImage s]![cboPro duct] & "*"))
ORDER BY tblProducts.ProdRef, tblLocations.LocationDesc;
SELECT tblProducts.ProductID, tblProducts.ProdRef, tblLocations.LocationDesc,
FROM (tblProducts LEFT JOIN tblLocations ON tblProducts.LocationID = tblLocations.LocationID) RIGHT JOIN tblInventoryDetails ON tblProducts.ProductID = tblInventoryDetails.Produc
GROUP BY tblProducts.ProductID, tblProducts.ProdRef, tblLocations.LocationDesc
HAVING (((tblProducts.ProdRef) Like "*" & [Forms]![frmSearchForProdu
ORDER BY tblProducts.ProdRef, tblLocations.LocationDesc;
ASKER
And tblProducts.ProdRef is the field I'm trying to do this with.
try this
SELECT tblProducts.ProductID, Left([tblProducts].[ProdRe f], InstrRev([tblProducts].[Pr odRef],"," )-1), tblLocations.LocationDesc, Sum([IncomingQty]-[SoldQty ]) AS [Inv Qty]
FROM (tblProducts LEFT JOIN tblLocations ON tblProducts.LocationID = tblLocations.LocationID) RIGHT JOIN tblInventoryDetails ON tblProducts.ProductID = tblInventoryDetails.Produc tID
GROUP BY tblProducts.ProductID, Left([tblProducts].[ProdRe f], InstrRev([tblProducts].[Pr odRef],"," )-1), tblLocations.LocationDesc
HAVING (((Left([tblProducts].[Pro dRef], InstrRev([tblProducts].[Pr odRef],"," )-1)) Like "*" & [Forms]![frmSearchForProdu ctsOrImage s]![cboPro duct] & "*"))
ORDER BY Left([tblProducts].[ProdRe f], InstrRev([tblProducts].[Pr odRef],"," )-1), tblLocations.LocationDesc;
SELECT tblProducts.ProductID, Left([tblProducts].[ProdRe
FROM (tblProducts LEFT JOIN tblLocations ON tblProducts.LocationID = tblLocations.LocationID) RIGHT JOIN tblInventoryDetails ON tblProducts.ProductID = tblInventoryDetails.Produc
GROUP BY tblProducts.ProductID, Left([tblProducts].[ProdRe
HAVING (((Left([tblProducts].[Pro
ORDER BY Left([tblProducts].[ProdRe
ASKER
Hmm that didn't work. Now the combo box retuned nothing.
ASKER
And if I just try to run the query I get the attached error.
error.jpg
error.jpg
create a function with a while loop incrementing a counter, character by character until there are no more commas, then return the counter and use it to derive right(string, len(str)-counter)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks to all three of you. I ended up using Rey's suggestion for timings sake but will keep record of the other two also.