peskywinnets
Registered User.
- Local time
- Today, 03:57
- Joined
- Feb 4, 2014
- Messages
- 576
So I want to pull in pricing information from Amazon for the goods I sell. Amazon, restrict such API requests to 20 products at a time ....I have about 180 products.
therefore I need to 'chop' my overall list of 180 products up into nine groups of 20 products, for example...
Product1,Product2,Product3,Product4...& so on up Product20
this list gets submitted with the remaining XML parsed
After the XML for the first 20 products has been parsed, I then need submit the next group of 20 products...
Product21,Product22,Product23 .....& so on up to Product40
I've managed to get the first group submitted, but I need a way of calling a sub routine/function that picks up where the last 'count' was left off.
I'm still finding my coding feet (very new to it all) & this is what I have so far (I'm sure it's very inelegant so welcome comments towards helping clean it up!)...
(note the use of the term 'ASIN' below can be taken to mean Product code)
but as you'll see myCounter is reset at the beginning of the function...which means every time I call the function only the same first 20 products will be returned) how can I get around this (I'm sure the answer is embarrassingly simple)
therefore I need to 'chop' my overall list of 180 products up into nine groups of 20 products, for example...
Product1,Product2,Product3,Product4...& so on up Product20
this list gets submitted with the remaining XML parsed
After the XML for the first 20 products has been parsed, I then need submit the next group of 20 products...
Product21,Product22,Product23 .....& so on up to Product40
I've managed to get the first group submitted, but I need a way of calling a sub routine/function that picks up where the last 'count' was left off.
I'm still finding my coding feet (very new to it all) & this is what I have so far (I'm sure it's very inelegant so welcome comments towards helping clean it up!)...
(note the use of the term 'ASIN' below can be taken to mean Product code)
Code:
Public Function ASINList() As String 'groups of 20 ASINs in SKU alphabetical order
Dim rst As DAO.Recordset
Dim myCounter As Long
myCounter = 1
Set rst = CurrentDb.OpenRecordset("Select * from tblProducts order by SKU ASC")
Dim ASINList1 As String
ASINList1 = ""
ASINList1 = rst!ASIN ' this bit populates the list with the first product having no preceding comma separator.
rst.MoveNext
myCounter = myCounter + 1
Do While Not rst.EOF
If myCounter < 21 Then
ASINList1 = ASINList1 + "," + rst!ASIN 'comma separated product codes.
myCounter = myCounter + 1
rst.MoveNext
Else
GoTo jmp 'this is pointless as the condition will never be met, but didn't know what else to put here!
End If
Loop
jmp:
rst.Close
Set rst = Nothing
ASINList = ASINList1 ' return the list of 20 product to the main code
End Function
but as you'll see myCounter is reset at the beginning of the function...which means every time I call the function only the same first 20 products will be returned) how can I get around this (I'm sure the answer is embarrassingly simple)
Last edited: