Post by John W. VinsonPost by tauntHello I'm trying to transfer a SQL query to Access and having no luck.
I was wondering if someone can post a query to add the check digit to
11 and 12 digit UPCs. I'm finding out that Access doesn't like
SUBSTRING commands or len commands (I was looking for (LEN(UPC) = 11)
and it errors out. Any help would be great.
Thanks
The Access not-quite-equivalent of SUBSTRING is MID. Len() should work. Could
you post your actual expression and the error you're getting?
--
John W. Vinson [MVP]
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see alsohttp://www.utteraccess.com
Well the database I'm doing it on has 11 digit UPCs, and 12. Here's
the coding:
INSERT INTO UPCR (ID, UPC, UPC1, UPC2, UPC3, UPC4, UPC5, UPC6,
UPC7, UPC8, UPC9, UPC10, UPC11, UPC12)
SELECT ID, UPC, SUBSTRING(UPC, 1, 1), SUBSTRING(UPC, 2, 1),
SUBSTRING(UPC, 3, 1), SUBSTRING(UPC, 4, 1), SUBSTRING(UPC, 5, 1),
SUBSTRING(UPC, 6, 1), SUBSTRING(UPC, 7, 1), SUBSTRING(UPC, 8, 1),
SUBSTRING(UPC, 9, 1), SUBSTRING(UPC, 10, 1), SUBSTRING(UPC, 11, 1),0
FROM Sfile
WHERE (LEN(UPC) = 11)
and
INSERT INTO UPCR (ID, UPC, UPC1, UPC2, UPC3, UPC4, UPC5, UPC6,
UPC7, UPC8, UPC9, UPC10, UPC11, UPC12)
SELECT ID, UPC, SUBSTRING(UPC, 12, 1), SUBSTRING(UPC, 1, 1),
SUBSTRING(UPC, 2, 1), SUBSTRING(UPC, 3, 1), SUBSTRING(UPC, 4, 1),
SUBSTRING(UPC, 5, 1), SUBSTRING(UPC, 6, 1), SUBSTRING(UPC, 7, 1),
SUBSTRING(UPC, 8, 1), SUBSTRING(UPC, 9, 1), SUBSTRING(UPC, 10, 1) ,
SUBSTRING(UPC, 11, 1)
FROM Sfile
WHERE (LEN(UPC) = 12)
and that's just the first part. I didn't know if there's an easier way
to do this.
Thanks