Page 1 of 1
[Solved] Accessing the document's data sources
Posted: Wed Nov 21, 2007 5:49 am
by jkordani
I am working with base and i need to write a few macros that take information from the tables and outputs it, and does calculations etc. Before all I needed to do was just tie UI forms to a filter builder, that got working thanks to Drew! But now I need to actually work with the data, not to mention be able to print it out and make a pager for it since the size of the output can get large. But I found that in order to use rowsets and queries based on my tables I had to register the base file as a data source in oo options. This may be an incorrect statement, maybe I typed something wrong, so if so please tell me. If not, then the problem with doing it that way is if the file ever gets moved, then the user has to go re register the file as a data source in oo options! Or is this also not the case? Am I missing something? So what im looking for is a way to get access to the current files datasource(s). I tried doing something like this.datasource or something, no avail. Anyone got any pointers?
Re: Accessing the document's data sources.
Posted: Wed Nov 21, 2007 6:05 am
by DrewJensen
Do you mean you want to call this routine from say a button on a form and then get access to the datasource used by that form?
or
You want to refer to an ODB file and get the datasource for it?
Thanks
Re: Accessing the document's data sources.
Posted: Wed Nov 21, 2007 6:27 am
by jkordani
the first one.
Re: Accessing the document's data sources.
Posted: Wed Nov 21, 2007 6:34 am
by DrewJensen
Alright, let me put together a decent little example for you...won;t take very long...but a bit more then a few minutes..OK
Re: Accessing the document's data sources.
Posted: Wed Nov 21, 2007 7:55 am
by jkordani
Wow, I've seen your other posts, how long have you been using this language? You make it seem so easy! Thanks for your help btw.
Re: Accessing the document's data sources.
Posted: Wed Nov 21, 2007 6:06 pm
by mobi-doc
In BASIC your form document has all the rowset/resultset functionality. You just access your root form with
Code: Select all
oForm=ThisComponent.drawpage.forms(0)
and then you can use methods like oForm.first, oForm.last, oForm.getString, etc...
To get access to the datasource of your form try
Code: Select all
oConn=ThisComponent.Parent.DataSource.getConnection("","")
and then you can execute queries with
Code: Select all
oResultSet=oConn.createStatement.executeQuery("the sql code goes here...")
have a nice day.
Re: Accessing the document's data sources.
Posted: Sun Nov 25, 2007 2:19 am
by jkordani
Thanks, that did the trick!