Trying to cycle through child records

M

Martin Williams

I'm trying to cycle through the child records of a current customer, in
order to calculate a total. Here is my code so far:

sub GetTransactionTotal()

dim drArray() as datarow
dim intCount, intCurrentCustomer as integer
dim dblSubTotal, dblTax, dblTotal as double

intCurrentCustomer = me.bindingcontext(dataset1, "Customer").position + 1

drArray = dataset1.customer(intCurrentCustomer).GetChildRows("DataRelation")
for intCount = 0 to drArray.GetUpperBound(0)
if drArray(intCount).item("Date Rented") = today.toshortdatestring then
dblSubTotal += drArray(intCount).item("Price")
else
exit for
end if
next

dblTax = dblSubtotal * .06
dblTotal = dblSubtotal + dblTax
txtSubtotal.text = dblSubtotal.tostring("c")
txtTax.text = dblTax.tostring("c")
txtTotal.text = dblTotal.tostring("c")

end sub

Basically, it's not doing anything. All I get is "$0.00". Thanks for all
responses.

Regards,
Martin Williams
 
A

Armin Zingler

Martin Williams said:
I'm trying to cycle through the child records of a current customer,
in order to calculate a total. Here is my code so far:


Have you already single-stepped through the procedure to find the fault?

dim drArray() as datarow
dim intCount, intCurrentCustomer as integer
dim dblSubTotal, dblTax, dblTotal as double

intCurrentCustomer = me.bindingcontext(dataset1, "Customer").position + 1

drArray = dataset1.customer(intCurrentCustomer).GetChildRows("DataRelation")
for intCount = 0 to drArray.GetUpperBound(0)

What does drArray.GetUpperBound(0) return?
if drArray(intCount).item("Date Rented") = today.toshortdatestring then

Is "Date Rented" a text or a date field?
dblSubTotal += drArray(intCount).item("Price")

Did you enabled Option Strict?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top