Ask Your Question
0

BASIC runtime error

asked 2016-12-13 03:26:51 +0100

FelipeRamirez gravatar image

Hi.

I am not an expert Libre Office Base, but I am trying to do some basic macro, and for some reason I am getting an error every time I click on the only form I have saying that I have a BASIC runtime error. Despite that, the MACRO seems to be doing its job anyhow.

I would appreciate if somebody could give me some advise here

This is the exact error message

  • BASIC runtime error. An exception occurred Type: com.sun.star.container.NoSuchElementException Message: There is no element named 'Citacion'..

*

A this is the code

sub S_SelectFile
    oform = thiscomponent.drawpage.forms.MainForm.SubFormCitaciones
    ofpkSelectFile = oform.getbyname("FileSelection")
    sUrl = converttourl(ofpkSelectFile.Text)
    for i = len(sUrl) to 1 step -1
        if mid(sUrl,i,1) = "/" then
             sFile = mid(sUrl, i+1, len(sUrl))
             exit for
        endif
    next i
        rem oform.updatestring(3,sFile)
        oform.updatestring(5,sUrl)
        if oform.isnew then
            oform.insertrow
        else
            oform.updaterow
        endif
end sub

Sub S_insert_url_to_Button
    oform = thiscomponent.drawpage.forms.MainForm.getbyname("SubFormCitaciones")
    oButton = oform.PushButtonCitacion
    oButton.TargetUrl = oform.Columns.getbyname("Citacion").getstring
end sub

By the way. There is a fiels named "Citacion" on the table called "Citaciones"

Regards

edit retag flag offensive close merge delete

Comments

Just from a quick glance at this, I think oform.Columns is in the recordset, not the form control. It's the data in your datasource, not how it is displayed on the screen. And depending on other factors, a recorset might not exist, even when it's associated control does. Other that that I have no idea what the code is trying to do. A bunch of embedded comments to say what's going on are sorely lacking. Pls, add code comments and re-submit.

EasyTrieve gravatar imageEasyTrieve ( 2017-02-06 21:27:04 +0100 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2016-12-14 00:25:01 +0100

Ratslinger gravatar image

Sorry for all the confusion and apologies for the code and earlier comments. Found the problem and it has nothing to do with the code presented above. If you had not presented the .odb it couldn't be solved.

The error is generated by a Before record change event on MainForm calling Sub S_insert_url_to_Button. So when the form was first opened and before the first data was loaded, the event occurs and generates the error because nothing is loaded yet. If this event is removed, the error goes away. However, since I don't know why this event was placed there it is not known what other circumstances it affects. The error does not affect further processing.

edit flag offensive delete link more

Comments

A little further checking shows that routine should be called from After record change event.

Ratslinger gravatar imageRatslinger ( 2016-12-14 02:41:38 +0100 )edit
0

answered 2016-12-13 17:07:40 +0100

FelipeRamirez gravatar image

updated 2016-12-13 21:51:34 +0100

Thanks for your prompt answer. I cheked with your changes and generate other errors.

If you look at the following link, you will see the database file, and the example that I used to creates my macro.

https://www.dropbox.com/sh/86yxblpfyp...

According to the example the following entense is just fine.

oButton.TargetUrl = oform.columns.getbyname("Citacion").getstring
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-12-13 03:26:51 +0100

Seen: 1,774 times

Last updated: Dec 14 '16