April15Hater
Accountant
- Local time
- Today, 16:12
- Joined
- Sep 12, 2008
- Messages
- 349
Hey guys. I'm running into a problem working with the LIKE operator in one of my queries that is defining a rowsource for a listbox on a form. I think this is a fairly simple thing, but I can't figure out how to make it work right.
Then entire SQL command is below, but here is the clause in question:
I think what I'm trying to do is best explained by an example. The listbox containing the SQL will be displaying tracking numbers that look like:
123-123
123-124
124-123
175-987
175-988
175-989
181-175
181-995
195-951
In txtTracking, I want to be able to type in say 175 and it only display 175-988 and 175-989. As it is, it filters really haphazardly. It returns anything that has a 1, 7, or a 5. Any help guys? I do have it set to requery on change in txtTracking, but I don't know if my code is off or what.
Then entire SQL command is below, but here is the clause in question:
Code:
(tblProductionTracking.TrackingNumber) Like "*" & [Forms]![frmProductionStep3b]![txtTracking] & "*"
I think what I'm trying to do is best explained by an example. The listbox containing the SQL will be displaying tracking numbers that look like:
123-123
123-124
124-123
175-987
175-988
175-989
181-175
181-995
195-951
In txtTracking, I want to be able to type in say 175 and it only display 175-988 and 175-989. As it is, it filters really haphazardly. It returns anything that has a 1, 7, or a 5. Any help guys? I do have it set to requery on change in txtTracking, but I don't know if my code is off or what.
Code:
SELECT tblProductionTracking.ProductionTrackingID, tblProductionTracking.ProductionID, tblProductionTracking.FunctionTrackingID, tblProductionTracking.TrackingNumber
FROM tblProductionTracking
WHERE (((tblProductionTracking.ProductionID)<>[Forms]![frmProductionStep3b]![txtProductionID]) AND ((tblProductionTracking.FunctionTrackingID)=[Forms]![frmProductionStep3b]![cboFunctionTrack]) AND ((tblProductionTracking.TrackingNumber) Like "*" & [Forms]![frmProductionStep3b]![txtTracking] & "*" And (tblProductionTracking.TrackingNumber) Not In (SELECT tblProductionTracking.TrackingNumber FROM tblProductionTracking WHERE (((tblProductionTracking.ProductionID)=[forms]![frmProductionStep3b]![txtProductionID]) AND ((tblProductionTracking.FunctionTrackingID)=[forms]![frmProductionStep3b]![cboFunctionTrack])))))
ORDER BY tblProductionTracking.FunctionTrackingID, tblProductionTracking.TrackingNumber;