Sorry for being a VBA rookie - I am decidedly in over my head! I've looked for similar code to borrow and didn't see anything similar. Crosstab isn't suited and neither is concatenate.
I’m trying to create a temp table from data that is in rows and I need to convert to columns so I can format a catalog of items with pictures and I need more than one item (row) per detail section
Catalog query results -
CATALOG ITEM PIC
1234 0001 \imagepath\image1.jpg
1234 0002 \imagepath\image2.jpg
1234 0003 \imagepath\image3.jpg
1234 0004 \imagepath\image4.jpg
1234 0005 \imagepath\image5.jpg
1234 0006 \imagepath\image6.jpg
Etc......
I need it to look like……
Temp Catalog Table
CATALOG|GROUP|ITEM1|PIC1|ITEM2|PIC2|ITEM3|PIC3
1234|1|0001|image1.jpg|0002|image2.jpg|0003|image3.jpg
1234|2|0004|image4.jpg|0005|image5.jpg|0006|image6.jpg
I want to put this in a loop, but I don’t know the VBA syntax
***********************************
Define recordset (how?)
SELECT * from table where catalog=[x] ORDER BY item
‘order by item so when they’re written into the temp table, they are already sorted
grp = 1
For each row in recordset
Do
For grp_inc in 1 to 3
do
Item[grp_inc] = currentrow.item
Pic[grp_inc] = currentrow.pic
grp_inc = grp_inc + 1
if grp_inc = 3
then grp = grp + 1 ‘if last loop, inc grp #
end if
nextrow
done
write catalog|grp|item1|pic1|item2|pic2|item3|pic3 to temp table (how?)
grpinc = 1
Done
***************************************
Thank you for helping!
I’m trying to create a temp table from data that is in rows and I need to convert to columns so I can format a catalog of items with pictures and I need more than one item (row) per detail section
Catalog query results -
CATALOG ITEM PIC
1234 0001 \imagepath\image1.jpg
1234 0002 \imagepath\image2.jpg
1234 0003 \imagepath\image3.jpg
1234 0004 \imagepath\image4.jpg
1234 0005 \imagepath\image5.jpg
1234 0006 \imagepath\image6.jpg
Etc......
I need it to look like……
Temp Catalog Table
CATALOG|GROUP|ITEM1|PIC1|ITEM2|PIC2|ITEM3|PIC3
1234|1|0001|image1.jpg|0002|image2.jpg|0003|image3.jpg
1234|2|0004|image4.jpg|0005|image5.jpg|0006|image6.jpg
I want to put this in a loop, but I don’t know the VBA syntax
***********************************
Define recordset (how?)
SELECT * from table where catalog=[x] ORDER BY item
‘order by item so when they’re written into the temp table, they are already sorted
grp = 1
For each row in recordset
Do
For grp_inc in 1 to 3
do
Item[grp_inc] = currentrow.item
Pic[grp_inc] = currentrow.pic
grp_inc = grp_inc + 1
if grp_inc = 3
then grp = grp + 1 ‘if last loop, inc grp #
end if
nextrow
done
write catalog|grp|item1|pic1|item2|pic2|item3|pic3 to temp table (how?)
grpinc = 1
Done
***************************************
Thank you for helping!