Ask Your Question
0

Check data source if empty

asked 2020-07-17 13:53:11 +0200

gkick gravatar image

Hi,

Scenario - Report is based on query, takes a bit of time to process, however I would like to show a message-box that there is nothing to print and exit the sub if the record-set is empty. I know I can do a row count on open forms, how can one do that with a query for a report without walking the set ? Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2020-07-21 19:28:09 +0200

gkick gravatar image

updated 2020-07-21 19:31:56 +0200

Had the solution all along ...

Sub reptest
Dim oForm as Object
    oForm = ThisComponent.Drawpage.Forms.getByName("MainForm") 
dim Connection,SQL as object
dim myVar AS INTEGER
    Connection=oForm.ActiveConnection 
    SQL=Connection.createStatement()
    result=SQL.executeQuery("SELECT COUNT(""id"") FROM ""tblDummy""" ) 
result.next
myVar = result.getInt(1)
If myVar = 0 THEN
    msgbox ("no result to report",16,"Report not executable")
    exit sub
else
    ThisDatabaseDocument.ReportDocuments.getbyname("rptInvoice").open
end if

End Sub

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-07-17 13:53:11 +0200

Seen: 25 times

Last updated: Jul 21