SUB lstCategories_OnChange
    
    Dim rsProds, opt, i, sProds

    tdProduct.innerhtml = "&nbsp"

    ' -------------------------------------
    ' Set the temporary recordset to the entire list of products
    ' -------------------------------------
    set rsProds = rsAllProducts
    
    ' -------------------------------------
    ' Create the recordset with the appropriate products
    ' -------------------------------------
    rsProds.Filter = "categoryId = " & lstCategories.value
   
    ' -------------------------------------
    ' Delete the current entries in the products list box
    ' -------------------------------------
    For i = 0 to (lstProducts.options.length-1)
        lstProducts.options.remove 0
    Next

    ' -------------------------------------
    ' Fill the list with the right products
    ' -------------------------------------
    Do until rsProds.eof
        set opt = document.createelement("option")
        opt.text= rsProds.Fields("ProductName")
        opt.Value = rsProds.Fields("ProductId")
        lstProducts.options.add opt
        set opt=nothing
        rsProds.MoveNext
    Loop

    ' -------------------------------------
    ' Clean Up
    ' -------------------------------------
    Set rsProds = Nothing
END SUB