Hey,
I tried to write some SQL to do this but I can't seem to get it to work.
When I wrote the code to submit new data and update existing records in the
database I was able to use .Submit. This doesn't seem to work when I try to
delete records. I get the following error - "InfoPath cannot submit the form.
The form does not contain any new data to submit to the data source."
I also tried to use .Query thinking that if in the query I had a delete
statement it would work. No luck - nothing happens.
Below is the code for both attempts. I'm sure I just missing something stupid.
Sub btnDeleteFiling_OnClick(eventObj)
'Store the original command text of the query adapter
Dim strOriginalCommand
strOriginalCommand = XDocument.QueryAdapter.Command
'Get the Filings data node
Dim queryFilings
Set queryFilings =
XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:queryFields/q:T_Filing")
'Get the activeFilingID
Dim objactiveFilingID
set objactiveFilingID =
XDocument.DOM.selectSingleNode("//dfs:myFields/my:activeFilingID")
'Build the new sql command to delete the filing
Dim strSQL
strSQL = "delete [T_Filing] " &_
"from [T_Filing] " &_
"where Filing_ID = " & objactiveFilingID.text & " " _
'Set the query adapter command to the new SQL text
XDocument.QueryAdapter.Command = strSQL
Dim DeleteFiling
set DeleteFiling = XDocument.QueryAdapter
'Execute the query
DeleteFiling.Submit
'XDocument.Query 'tried this as well - did not work
If eventObj.ReturnStatus = True Then
XDocument.UI.Alert "Filing was successfully deleted!"
Else
XDocument.UI.Alert "Delete failed!"
End If
XDocument.View.SwitchView "Search"
XDocument.View.ForceUpdate
'Reset the query adapter back to the original command so it is ready for
the next query
XDocument.QueryAdapter.Command = strOriginalCommand
End Sub
Any help would be greatly appreciated! Thanks
--
-ridawg
ridawg said:
Yeah - I jus realized the whole removechild is the wrong approach. Basically,
my form queries my database and returns some data. The submit code I already
wrote uses the queryadapter. My guess is I should be using the queryadapter
and writing some SQL code. Does that make sense?