Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert function---string to number

Status
Not open for further replies.

vani65

Programmer
May 19, 2003
101
AU
Hi All
I need a report based on the criteria(number range)say: "BaleNo(USCNo.) 0302 to BaleNo(USCNo) 0306". The report should display all records between 0302 and 0306. I can't use "Between" criteria as datatype for BaleNo is Text. I used following Union query with parameters and in the where clause Like function with the following syntax(you can see in SQL). With this criteria my report is displaying only 0302 and 0306 records but not picking up in between records say 0303, 0304, 0305.I know something wrong with my syntax, I guess I have to use convert function(string to number) but I am not sure with the syntax. Could anyone suggest me the correct syntax so that all the records between 0302 to 0306 are displayed in my report.


PARAMETERS FORMS!Form1![USCNo1] Text, FORMS!Form1![USCNo2] Text, zz_RepPar.StockStatusId Text;
SELECT tblStock.StockID, tblStock.Description, tblStock.UnitOfMeasureID, tblPattern.BaleNo, tblPattern.Pattern, tblPattern.Dye, tblPattern.QuantityReceived, tblPattern.Quantity, tblPattern.JobID, tblPattern.SBN, tblPattern.Notation, tblPattern.LocationID, tblPattern.ActualCost, [Quantity]*[ActualCost] AS Total, tblPattern.USCCategoryID, tlkpStockStatus.StockStatusDescr, zz_RepPar.TransDate
FROM tblStock RIGHT JOIN ((zz_RepPar LEFT JOIN tlkpStockStatus ON zz_RepPar.StockStatusID = tlkpStockStatus.StockStatusID) LEFT JOIN tblPattern ON zz_RepPar.StockStatusID = tblPattern.StockStatusID) ON tblStock.StockID = tblPattern.StockID
WHERE tblPattern.BaleNo Like Left(FORMS!Form1![USCNo1],4)& &quot;*&quot; AND((tblPattern.Quantity)<>0)
UNION
SELECT tblStock.StockID, tblStock.Description, tblStock.UnitOfMeasureID, tblPattern.BaleNo, tblPattern.Pattern, tblPattern.Dye, tblPattern.QuantityReceived, tblPattern.Quantity, tblPattern.JobID, tblPattern.SBN, tblPattern.Notation, tblPattern.LocationID, tblPattern.ActualCost, [Quantity]*[ActualCost] AS Total, tblPattern.USCCategoryID, tlkpStockStatus.StockStatusDescr, zz_RepPar.TransDate
FROM tblStock RIGHT JOIN ((zz_RepPar LEFT JOIN tlkpStockStatus ON zz_RepPar.StockStatusID = tlkpStockStatus.StockStatusID) LEFT JOIN tblPattern ON zz_RepPar.StockStatusID = tblPattern.StockStatusID) ON tblStock.StockID = tblPattern.StockID
WHERE tblPattern.BaleNo Like Left(FORMS!Form1![USCNo2],4)& &quot;*&quot; AND((tblPattern.Quantity)<>0);
 
Hi
Thanks for replying. I tried the code but it didn't work.Could anyone please help me with this
 
Try this one:
CLng([text])
Should give you back the number (IntLong)in a string.

George
 
When i was using following SQLs:
1st SQL no data fetch and when I use 2nd SQL system
brings only the records of related to uscno2 ie the number given in uscno2. Say I enter 0302 in uscno1 and 0304 in uscno2 records of only 0304 are displayed. I want all records between 0302 and 0304. Could anyone tell
me where I was wrong.


1st SQL

PARAMETERS[Date to summerise] date, [Date to summerise1] date; SELECT tblStock.StockID, tblStock.Description, tblStock.UnitOfMeasureID,
Format(CDate(&quot;00&quot; & Mid(tblPattern.BaleNo,3,2) &
Mid(tblPattern.BaleNo,1,2)),'yymm') AS Expr1,
tblPattern.Pattern, tblPattern.Dye, tblPattern.QuantityReceived,
tblPattern.Quantity, tblPattern.JobID, tblPattern.SBN, tblPattern.Notation
tblPattern.LocationID, tblPattern.ActualCost, [Quantity]*[ActualCost] AS
Total, zz_RepPar.StockStatusID, tblPattern.USCCategoryID,
tlkpStockStatus.StockStatusDescr
FROM tblStock RIGHT JOIN ((zz_RepPar LEFT JOIN tlkpStockStatus ON
zz_RepPar.StockStatusID = tlkpStockStatus.StockStatusID) LEFT JOIN
tblPattern ON zz_RepPar.StockStatusID = tblPattern.StockStatusID) ON
tblStock.StockID = tblPattern.StockID
WHERE Format(CDate(&quot;00&quot; & Mid((tblPattern.BaleNo),3,2) &
Mid((tblPattern.BaleNo),1,2)),'yymm') >= [Date to summerise] And
Format(CDate(&quot;00&quot; & Mid((tblPattern.BaleNo),3,2) &
Mid((tblPattern.BaleNo),1,2)),'yymm') <=
[Date to summerise1] AND ((tblPattern.Quantity)<>0);

2nd SQL

SELECT tblStock.StockID, tblStock.Description,
tblStock.UnitOfMeasureID, Format(CDate(&quot;00&quot; & Mid([BaleNo],3,2) &
Mid([BaleNo],1,2)),'yymm') AS Expr1, tblPattern.Pattern, tblPattern.Dye,
tblPattern.QuantityReceived, tblPattern.Quantity, tblPattern.JobID,
tblPattern.SBN, tblPattern.Notation, tblPattern.LocationID,
tblPattern.ActualCost, [Quantity]*[ActualCost] AS Total,
zz_RepPar.StockStatusID, tblPattern.USCCategoryID,
tlkpStockStatus.StockStatusDescr
FROM tblStock RIGHT JOIN ((zz_RepPar LEFT JOIN tlkpStockStatus ON
zz_RepPar.StockStatusID = tlkpStockStatus.StockStatusID) LEFT JOIN
tblPattern ON zz_RepPar.StockStatusID = tblPattern.StockStatusID) ON
tblStock.StockID = tblPattern.StockID
WHERE (((Format(CDate(&quot;00&quot; & Mid([BaleNo],3,2) &
Mid([BaleNo],1,2)),'yymm')) Between [forms]![form1]![uscno1] And
[forms]![form1]![uscno2]) AND ((tblPattern.Quantity)<>0));


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top