We have a personal reimbursement application where they enter some basic information about the user, then can enter 1 or more expense items into a repeating table in a repeating section. Two of the fields in the repeating table are Purpose and Category. Purpose is a drop down list box where the choices have been entered manually. Category is a drop down list box which uses a data source to query a SQL table based on the Purpose chosen. The last bit of code for the Purpose.OnChange event populates the Category drop down box:
'PopulateCategory
If e.Site.text <> "" Or e.Site.text <> "Select" Then
Dim adapter As ADOAdapterObject
adapter = CType(thisXDocument.DataAdapters("PurposeCategory"), ADOAdapterObject)
adapter.Command = String.Format("SELECT Category from bpiPersonalReimbursementPurposeCategory where Purpose = '" + e.Site.text + "' order by Purpose,Category")
adapter.Query()
Dim adap As New SqlDataAdapter("SELECT Category from bpiPersonalReimbursementPurposeCategory where Purpose = '" + e.Site.text + "' order by Purpose,Category", strConnString2)
Dim dsDat As New DataSet
adap.Fill(dsDat)
If the uses stays on that records they can switch between different Categories. They can also switch to a different Purpose and then a new list of Categories will display in the drop down box.
When the user enters another expense item, if they go back to one they entered previously and choose the Category drop down, only the selected Category displays, not the entire list related to the Purpose.
I have tried adding the above code to the Category field, modified a bit since we're not on Purpose, but now, after they've entered a second expense item and go back to the first, the Category choices for the second expense item appear in the first one. So it seems to be using the Purpose from the current expense item to populate Category fields on other expense items.
It seems like this should be simple. I'm dimming relevant variables as follows in Category.onChange
Dim Category As IXMLDOMNode = e.Site
Dim Purpose As IXMLDOMNode = Category.selectSingleNode("../ns1:Purpose")
Should Purpose reflect the purpose of the current expense item?
Any help would be appreciated. We've struggled with this problem for several years but I've finally been told that it's time to fix it. Thanks in advance.
Mary Mc