| View previous topic :: View next topic |
| Author |
Message |
edwardrussia General User

Joined: 21 Oct 2010 Posts: 29
|
Posted: Sat Jun 11, 2011 2:29 pm Post subject: [solved] How to change Base form controls from macro |
|
|
I've made a form document in Base, which contains a lot of controls. I'm trying to write a macro which will change some properties of the controls/dataforms.
I would be grateful if someone could link me to somewhere which shows how to set each of the attributes. I only know a couple (e.g. button.TargetURL to, obviously , set the target URL of a button) but I can't find a list of them all.
I specifically need to set the "list content" of a list box and the "content" of a data form, but a link to a list would be the most useful thing so I don't need to ask a similar question next time.
Thank you for any help you can give me!
Last edited by edwardrussia on Tue Jun 14, 2011 11:56 am; edited 1 time in total |
|
| Back to top |
|
 |
RPG Super User

Joined: 24 Apr 2008 Posts: 2696 Location: Apeldoorn, Netherland
|
Posted: Sat Jun 11, 2011 3:27 pm Post subject: |
|
|
Hello
Search on the author name Voobase he does have written a lot about listboxes and macros.
It seems to me you want have a cascading listbox. Use the method of Villeroy: you need not any code.
You can find here a tutorial written by Arineckaig. It is on the end of the first post
http://user.services.openoffice.org/en/forum/viewtopic.php?f=83&t=28235
Romke |
|
| Back to top |
|
 |
edwardrussia General User

Joined: 21 Oct 2010 Posts: 29
|
Posted: Sun Jun 12, 2011 1:08 pm Post subject: |
|
|
I'm very grateful for your links, but after a couple of hours of browsing through them, I still can't find the information I've been looking for.
I know you can set the target URL of a button by putting this in your macro:
| Code: | | button.TargetURL="http://www.site.com" |
And I want to change the SQL which a list box uses for its "list content", and also the SQL a dataform uses for its "content", in a similar way:
| Code: | listbox.??????="SELECT...."
dataform.??????="SELECT...." |
Please could you help me fill in the ?????? gaps? Is there a list online of how to refer to all the form and form control properties in macros?
Thanks for spending your valuable time on an inexperienced OOo user like me!
Ed |
|
| Back to top |
|
 |
RPG Super User

Joined: 24 Apr 2008 Posts: 2696 Location: Apeldoorn, Netherland
|
Posted: Sun Jun 12, 2011 2:46 pm Post subject: |
|
|
Hello
I think learn using the Xray tool, you can find the link in the API forum.
http://www.oooforum.org/forum/viewtopic.phtml?t=98949&highlight=targeturl
maybe you need for the listbox
listbox.source(0)="Select .."
It seems you want use cascading listboxes or something else and then search for post of Voobase. I think this can help you.
http://www.oooforum.org/forum/viewtopic.phtml?t=74688&highlight=listbox+sub. For listboxes it is not only one property but sometimes more then one.
Read special the comments of Voobase. If macros are to difficult then try to do it without macro. Maybe you think it is difficult but then you have only the problem of SQL.
For the form you need the property command and reload
Romke |
|
| Back to top |
|
 |
RPG Super User

Joined: 24 Apr 2008 Posts: 2696 Location: Apeldoorn, Netherland
|
Posted: Sun Jun 12, 2011 2:59 pm Post subject: |
|
|
Hello
For your information: I use the next code in a form document for connecting a subform to an other mainform. At the same time I move a frame to an other place on the screen. But on this moment It does not work. The reason is a bug in LibO/OOo
| Code: | sub Categorie_verbinden (oEvent as object)
oMemoForm.command=sTableName
oMemoForm.commandtype=0
oMemoForm.applyfilter=true
oMemoForm.reload
end sub |
Romke |
|
| Back to top |
|
 |
edwardrussia General User

Joined: 21 Oct 2010 Posts: 29
|
Posted: Mon Jun 13, 2011 12:36 pm Post subject: |
|
|
Thanks for the links. I've been browsing through them. I tried this piece of code, based on examples by Voobase, but it gives an error message, "Object variable not set" in the listbox.ListSource line. Xray says ListSource is a property of the object, and even gives its current value, but I can't seem to set it from the macro.
| Code: | REM define search activities dataform
searchactivitiesform = ThisComponent.DrawPage.Forms.getbyname("Search activities")
REM define listbox
listbox = searchactivitiesform.getbyname("Grammar Point")
REM print table source
listbox.ListSource = "SELECT ""Grammar"", ""Grammar code"" FROM ""Grammar points"" ORDER BY ""Grammar""" |
Have I missed an obvious error by me? |
|
| Back to top |
|
 |
RPG Super User

Joined: 24 Apr 2008 Posts: 2696 Location: Apeldoorn, Netherland
|
Posted: Mon Jun 13, 2011 5:37 pm Post subject: |
|
|
Hello
| Voobase wrote: | dim new_sql(0) As string
dim olist as variant
oList= aDataForm.getbyname("lbClass")
new_sql(0) = "SELECT ""ClassName"", ""ID"" FROM ""Classes"" WHERE ""Category_FK"" = '" & aCategory & "'"
oList.ListSource = new_sql |
http://www.oooforum.org/forum/viewtopic.phtml?t=71974&postdays=0&postorder=asc&highlight=listsource++sub&start=15
Voobase makes first an array and stores this to the property. I did think that is the same as I use: listsource(0). But I did a little test and it was not working.
| Code: | sub opr
dim oForm,oListBox
oForm=thiscomponent.drawpage.forms.getbyindex(1)
oListBox=oForm.getbyname("List Box 1")
print oListBox.listsource(0)
oListBox.listsource=array("Select ""thisvjgjgalue"" from ""nothing""")
print oListBox.listsource(0)
end sub |
I do not always remember those setting correct from head and for that reason I always point to Voobase for the listboxes. For me own I have a big list where I copy parts.
Romke |
|
| Back to top |
|
 |
edwardrussia General User

Joined: 21 Oct 2010 Posts: 29
|
Posted: Tue Jun 14, 2011 11:56 am Post subject: |
|
|
Aha! Thanks for the clarification, Romke. I'd never have guessed that in a million years. It's a very good thing for novices like me that people like you help us so much  |
|
| Back to top |
|
 |
|