0 Replies Latest reply on Oct 20, 2014 12:20 PM by tehinternets

    How to handle 0 records returned via ODBC connection?

    tehinternets Level 1



      I am connecting my form via ODBC to an MS Access database with FormCalc XFA.  I know that's not ideal, but it works.   I am stuck however on how to handle errors when the form is not able to return a record due to a bad search string.


      Typically I am expecting one unique record to be returned, however at times there is no match based upon what the user has entered into the search field.  I am trying to 'catch' the error and give them a custom message I write, or no error at all.


      My Data Connection name is:   EstabSearchResults

      My search field name is:   EstabSearchField


      Here is what is run on the On Exit event when the user leaves the EstabSearchField:


      var oDC = Ref($sourceSet.EstabSearchResults.clone(1))

      oDC.#command.query.commandType = "text"

      oDC.#command.query.select = concat("SELECT Blah, BLah2, Foo, Bar FROM TableName WHERE (Something LIKE '",EstabSearchField.rawValue,"');")




      If there's now records however, I get:    [A whole bunch of Adobe gibberish that makes sense to end-users]  Error:  No records in datasource. 


      I'm having a difficult time coming up with a way to handle it when there is no records and perform addition customized logic if that happens.


      Any ideas?