This XPath will access a ticketID, but you must specify which one you want. To use some of the SQL stuff that I suggested above check out the following code:
XDocument.QueryAdapter.Command = "SELECT CustomerID FROM Customers ORDER BY CustomerID DESC";
XDocument.Query();
XDocument.DOM.selectSingleNode( "/dfs:myFields/my:lastID" ).text = XDocument.DOM.selectSingleNode( "/dfs:myFields/dfs:dataFields/d:Customers/@CustomerID" ).text;
NOTE: The above code was something that I created after designing a new blank form with a connection to NWind.mdb (the Microsoft sample database). You will have to edit the XPath statements and the SQL statement to match your solution.
Once the above code is run it will set the helper node (my:lastID) to the ID that returns last with a natural ordering. In you case this will be the largest number.
I'm sorry for suggesting the LIMIT clause, it seems that Microsoft Jet SQL doesn't allow this. However, you could use a WHERE clause to achieve something similiar. The main reason for using a LIMIT clause is performance reasons. See the following link for further reference:
http://office.microsoft.com/en-us/assistance/HP010322871033.aspx
I hope this helps, if you want to e-mail me your e-mail address (the forum hides actual e-mail addresses from us) I will mail you the .xsn I just created so you can use it as an example.
---------------
Matt Faus
InfoPath Dev Texas
Matt Faus / Microsoft InfoPath MVPQdabra® Software / Streamline data gathering to turn process into knowledge