Results 1 to 2 of 2

Thread: wahhh, help me please

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2004
    Posts
    1

    Unhappy wahhh, help me please

    I am new to functions and arrays, and my brain is now officially jello... runny too long in the sun jello...

    I need to dynamically create an array, sort of...

    Here is the method that i am using for static content:

    Code:
    Function GetItemParameters(iItemID)
    Dim aParameters
      Select Case iItemID
        Case 1 
          aParameters = Array("ItemID", "CategoryID", "15.00")
       Case 2
          aParameters = Array("ItemID", "CategoryID", "17.50")
       Case 3
         aParameters = Array("ItemID", "CategoryID", "35.00")
      End Select
    GetItemParameters = aParameters
    End Function
    However, I need to populate it from a database. This is for a shopping cart, and there is no way that i'm going to be able to list the items manually, because it can change dynamically. I can't find any tutorials to show me how to do that.

    I can count the Item records for each Category (relational tables), however, i can't for the life of me figure out how to generate this case select statement dynamically.

    this is the best that i've come up w/ and of course, it doesn't work:

    Code:
    Function GetItemParameters(iItemID)
      i=0
      j=CInt(objItemsRS.RecordCount-1)
      
      Select Case iItemID
      for i=i to j
      Case CInt(i)
       aParameters(i) = Array(objItemsRS("ItemID"),objItemsRS("CatID"), &_
    objItemsRS("ItemHeader"),objItemsRS("ItemSubHeader"), &_
    objItemsRS("ItemPrice"),objItemsRS("ItemSalePrice"), &_
    objItemsRS("ItemImg"),objItemsRS("ItemSKU"))
      Next
      End Select
    GetItemParameters = aParameters
    End Function
    can anyone help?

  2. #2
    Junior Member
    Join Date
    Nov 2003
    Posts
    22
    I may be missing something, but why not just loop through the recordset, checking the iItemID variable against the ItemID field in the database?

    Something like:

    VB Code:
    1. objItemsRS.MoveFirst
    2. Do Until objItemsRS.EOF
    3.   If objItemsRS.Fields("ItemID") = iItemID Then
    4.     ' We now know which one they picked ...
    5.     ' Grab the other information for this record
    6.     ' from the recordset.
    7.   End If
    8.   objItemsRS.MoveNext
    9. Loop

    Hope this helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width