Update row in repeating table

F

Francisco

Hello all,

I have a repeating table with 3 columns (Start Date, End Date, No. of Days).
I have a function that calculates the number of business days between the two
date columns and need to update the No. of Days column accordingly. It works
fine for the first row but for subsequent rows I just cannot make it work. I
have read all the threads concerning this topic and just cannot figure this
out. No excuse but I am a newbie, so I would appreciate it if you explain it
as simple as possible. Thank you all for your time.
 
B

Ben Walters

Hey Francisco,
Can you please provide some more details on your issue
1: What version of InfoPath are you using?
2: How are you firing off the code to calculate the number of days?


Cheers
Ben Walters
 
F

Francisco

Ben,

I am firing the code after the end date is populated. How can I update the
current row if the user changes the dates. I am using the last() function to
update the rows but how can I update the current row. thank you for your
time.

Public Sub calculateBusinessDays()
Try
Dim startDate As String =
firm.GetNodeValue("//my:holderStartDate")
Dim endDate As String =
firm.GetNodeValue("//my:holderEndDate")

Dim lNumberofDays As Long = DateDiff(DateInterval.Day,
CDate(startDate), CDate(endDate))
Dim lCounter As Long = 0
Dim lBusinessDays As Long = 0
Dim dDayCounter As Date

Do While lCounter < lNumberofDays
dDayCounter = DateAdd(DateInterval.Day, lCounter + 1,
CDate(startDate))
If Weekday(dDayCounter) <> 1 And Weekday(dDayCounter) <>
6 Then
lBusinessDays = lBusinessDays + 1
End If
lCounter = lCounter + 1
Loop

Call
firm.SetNodeValue("/my:lw/my:signedData/my:calDates[last()]/my:businessDays",
lBusinessDays, True)

Catch ex As Exception
firm.LogException(ex.Message, ex.ToString, ex.StackTrace)
Finally
firm.TraceUnindent()
End Try
End Sub
 

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