0

I could not figure out whats the problem is

Sub Reportstart(oEvent As Object)
Dim oFeld As Object
Dim oForm As Object
Dim oDocument As Object
Dim oDocView As Object
Dim Arg()
oField = oEvent.Source.Model
oForm = oField.Parent
sURL = oForm.DataSourceName
oDocument = StarDesktop.loadComponentFromURL(sURL, "C:\Users\Nameless\Desktop\Latest.odb", 0, Arg() )
oDocView = oDocument.CurrentController.Frame.ContainerWindow
oDocView.Visible = False
oDocument.getCurrentController().connect
Wait(100)
oDocument.ReportDocuments.getByName("report_student").open
oDocument.close(True)
End Sub'

The error is BASIC runtime error. Argument is not optional.

Micah
  • 3
  • 2
  • 1
    When you get the error, it will highlight a line. Which line? Then look at the function you are using on that line, and find the documentation for it, and look at which arguments are required, and compare it to what you have. – braX Jun 24 '20 at 05:56
  • oField = oEvent.Source.Model . this line . – Micah Jun 24 '20 at 06:21
  • and im already correct this line 'Dim oFeld As Object' to 'Dim oField As Object – Micah Jun 24 '20 at 06:27
  • Did you look at the documentation for that object? When you use all `Object` variables like that and provide no information about them in your post, it's going to be quite difficult for anyone to be able to help you. Start by figuring out what type of object `oEvent` is... – braX Jun 24 '20 at 09:02
  • This language is LibreOffice Basic, not VBA (Microsoft Office), so please remove the `vba` tag. – Jim K Jun 24 '20 at 17:48

1 Answers1

0

Reportstart requires an argument oEvent, and the way you executed it, the subroutine was not given any argument.

The macro was designed to be called from an event handler of a control, for example, the Execute action of a push button on a Base form. Perhaps you executed the subroutine from the LibreOffice Basic IDE instead.

Related: https://ask.libreoffice.org/en/question/192344/argument-is-not-optional/

Jim K
  • 12,824
  • 2
  • 22
  • 51