By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,996 Members | 1,179 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,996 IT Pros & Developers. It's quick & easy.

Trying to cycle through child records

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Martin Williams" <ma*******@comcast.net> schrieb
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?
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")
Basically, it's not doing anything. All I get is "$0.00". Thanks
for all responses.



--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.