I have set up a reference library that includes quotes. One of the columns in the reference table is for a pdf link to open the reference document. I have set up a form (see below) for a query (see SQL below) to search for word/phrase in a title. When a title is selected, I click on the “Open Document” button to view the document’s pdf using a macro (see the macro below).
.
This works well unless a search does not turn up a document. In that Case, I get the error shown below plus a window opens up with my macro that highlights the point in the macro that there is a problem (see below). If I disable macros and repeat a search that returns void, there is no error and the form is ready for a new search.
.
This happens with MariaDB and HSQLDB. I am running OpenSUSE Tumbleweed and using LO 7.4.3.2.
.
Can anyone tell me what is missing in my query SQL or in my macro to resolve this error?
.
Thank You
Hello,
Add error process & display a message when this occurs.
.
https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03050500.html
Thank you for a quick reply @Ratslinger.
I am not a programmer. I did read information at the link you provided and understand the concept, but I am unable to translate the example into my macro to have an “On Error GoTo” statement. My macro is:
option explicit
Sub FormReferenceDocpdf
Dim oForm as Object
Dim oButton as Object
oform = thiscomponent.drawpage.forms.getbyname("MainForm_Qry")
If oForm.isnew Then Exit Sub
oButton = oform.pbLink
oButton.TargetUrl = oform.Columns.getbyname("Link").getstring
End Sub
How do I, where do I begin, or where can I find more examples to get this up and running?
.
Is there a way to put another if statement in for the oForm such that if there is no oForm then I can Exit Sub? Something along the lines of:
If oForm.<?????> Then Exit Sub [Where <????> is a programming term]
Try this:
option explicit
Sub FormReferenceDocpdf
Dim oForm as Object
Dim oButton as Object
On error goto RecordNotFound
oform = thiscomponent.drawpage.forms.getbyname("MainForm_Qry")
If oForm.isnew Then Exit Sub
oButton = oform.pbLink
oButton.TargetUrl = oform.Columns.getbyname("Link").getstring
Exit Sub
RecordNotFound:
MsgBox "Requested record not there!"
End Sub