Difference between revisions of "MSA-Base Faq"
m (→A new entry)
m (→Where is findfirst?)
|Line 164:||Line 164:|
FindFirst = notFound
FindFirst = notFound
colIDX = oRS.FindColumn( ColName )
colIDX = oRS.FindColumn( ColName )
if oRS.getString( colIDX ) <> Searchval
if oRS.isAfterLast then
FindFirst = oRS.getBookMark
while oRS.isAfterLast <> True
while oRS.isAfterLast <> True
Revision as of 01:18, 11 March 2007
This is a user community effort - add to the knowledge base if you can.
Please however try to keep the questions and answers general. If there is an answer regarding a feature specific version of MSA then include the version number also.
Specifically, please only update the wiki if you have an answer for the question you are adding. ( If you may need to get back shortly with the answer don't let that stop you from getting the question in first however - just come back before long )
- 1 Can I use Microsoft Access databases (.mdb) in Base?
- 2 Can I read my Base database from MS Access?
- 3 Can I create an Access database (mdb file) with Base?
- 4 Can I create a Switchboard in Base?
- 5 Our Access databases uses "Workgroup Security" to control group/user permission to view/maintain data?
- 6 Is a Form in Base different from a Form in MSA?
- 7 Where are the Delete / Upate queries?
- 8 I want to filter my form based on the contents of a combobox?
- 9 Converting my VBA modules to Base modules
- 10 If I use Lookup fields/columns in my Access tables what can I do in Base?
- 11 How do I use Domain Aggregate functions in Base?
- 12 How do I add Calculated Controls to my forms and reports?
Can I use Microsoft Access databases (.mdb) in Base?
On Windows: yes. You cannot open them directly via
File|Open, but you can access the data therein. For this, you need the Microsoft Data Access Components, which are available from Microsoft for free. (In Windows XP, they're already included, so you need them for older Windows versions only.)
Then, go to
File|New|Database, choose "Connect to an existing database", and select the "Microsoft Access" database type from the list. On the next page, you then select the .mdb file you want to access.
If your database does not have a password, this will allow you to read and update the data in your Access tables. If your database has a password, try ADO instead.
You cannot read / modify or use the Access forms, queries, or reports.
Can I read my Base database from MS Access?
There is no way to use the table linking mechanism in Access to connect to a Base database.
It is possible for a Base database to update data in the Access database. At this time this will require however that the Access database be opened and locked by the Base file.
Data could also be passed back to the Access database by creating a linked CSV file in the Base database. Then linking to this CSV file to a table in the Access database.
Can I create an Access database (mdb file) with Base?
No. Base can not create a new Access database file; or new tables, queries, forms etc. within an existing mdb file.
Can I create a Switchboard in Base?
Base does not currently have a switchboard style form wizard. It is possible to achieve a very similar effect however using either of two techniques.
Opening a default form via a macro
Using a stand alone form to launch the Base database
Our Access databases uses "Workgroup Security" to control group/user permission to view/maintain data?
This question points out what is a fundamental difference between OOoBase and MS Access (MSA). In the case of MSA there is one and only one database engine in use - although you may link tables in MSA to external datasource - MS Jet is still the only database engine actually used by MSA.
In Base (OOoBase) this is not the case at all. The Base database document is simply a front end (client application) to a variety of database engines. In one of these forms it embeds a HSQLDB database into the ODB file itself, many people simply see this as the only Base database format. That is totally mistaken. In this instance of an embedded database there is no support for multiple users and of course no support for groups therefore. However, that is only one of the ways Base can be configured.
You are free to use Base as the front end to a HSQLDB database in server mode. HSQLDB is a very small footprint, low administration database engine and in server mode has full support for users / groups. For larger numbers of users you could just as easily configure Base to work with MySQL, PostgrSQL, Firebird, Oracle, or MS SQL Server.
There is another significant difference between MSA and Base regarding this then. In MSA you would deploy one MDB (or one of its variants ) file, then have each user in the workgroup see this file and open it.
In Base each user would have their own ODB file and each of these would be connected to the shared data server. In this way each user would have their own space for custom queries and reports - but it makes distribution of common forms, queries and reports more work.
Is a Form in Base different from a Form in MSA?
Yes. There are very real differences between how Forms are implemented in Access and Base.
Virtual forms within Base forms
Where are the Delete / Upate queries?
Base does not currently support building delete / insert / update queries in the designer.
using the Query Designer
You can achieve the equivalent actions in the GUI using the designer and or SQL commands.
using a macro
I want to filter my form based on the contents of a combobox?
Converting my VBA modules to Base modules
What happened to me?
There is no exact duplicate to the ME psuedo variable in VBA.
In Access VBA 'me' has attributes of two separate objects in OOoBasic: TextDocument and DataForm
The TextDocument object would be used for controlling the window size and placement on the screen for instance.
The DataForm meanwhile supports result set functions, such as First, Filter, InsertRow.
In OOoBasic the psuedo variable thisComponent normaly would be the TextDocument, while thisComponent.DrawPage.Forms(0) meanwhile would reference the first DataForm owned by the TextDocument.
Perhaps a still closer equivilant is to use the object ownership hierarchy to get to the form. For example if we had a single table form with a button, then in the macro called by the 'onClick' or as OOBase calls it the 'When initializing' event we would do this: Create a macro in a library named onButtonClick( oEv as object )
sub onButtonClick( oEv as object ) ' oEv is the event object passed automatically ' it has a property SOURCE which is the ' button that initiated this call dim oForm as variant oForm = oEv.Source.Model.Parent ' oForm is now the virtual form objct dim oDocument as variant oDocument = thisComponent ' oDocument is now the textDocument displayed in ' the window on screen end sub
Where is findfirst?
Base does not appear to have a FindFirst function on the rowset like MS Access, what is the equivalent Base function?
MSAccess VBA example:
Say there is a VB combo box which lists all the prospects in the database and allows the user to select a particular prospect and then have the form automatically go to that person's data record.
Private Sub Find_Combo_AfterUpdate() Dim strCriteria As String strCriteria = "[Prospect_ID] =" & Me.Find_Combo Me.recordsetclone.FindFirst (strCriteria) If me.recordsetclone.NoMatch Then MsgBox "No entry found" Else Form_F_Prospects.Bookmark = me.recordsetclone.Bookmark End If End Sub
For this type of simple single column search it is easy enough to create our own find first equivalent with OOoBasic:
Sub Find_Combo_AfterUpdate( OEv as Object) ' Oev is the event object automatically sent ' to sub procedure call ' Oev will have a property Source ' that is the control that triggered ' the call to this procedure Dim oForm as variant ' The dataform obejct Dim oComboBox as variant ' The combobox control Dim oBkMark as variant oForm = oEv.Source.Model.Parent oComboBox = oForm.getByName( "Find_Combo" ) oBkMark = FindFirst( oForm.CreateResultSet(), "Prospect_ID", oComboBox.Text ) ' oForm.CreateResultSet() is equivilant here to me.recordsetclone if not IsEmpty( oBkMark ) then oForm.moveToBookmark( oBkMark ) else msgBox( oComboBox.Text & " not found" ) end if end sub
function FindFirst( oRS as variant, ColName as string, SearchVal as string ) as variant ' oRS is a resultSet object ' ColName is the name of a column in the resultset ' SearchVal is dim colIDX as integer dim NotFound as variant FindFirst = notFound colIDX = oRS.FindColumn( ColName ) oRS.First do if oRS.getString( colIDX ) <> Searchval oRS.Next if oRS.isAfterLast then exit do endif else FindFirst = oRS.getBookMark exit do end if loop while oRS.isAfterLast <> True end function
How do I set the filter for a sub-form only?
Is there an equivalent to DoCmd RunSQL
Yes, in OOoBase you would use either a Statement or PreparedStatement object to achieve the same function. With OOoBase you must also decide between using execute and executeUpdate.
For example if you had the VBA line
DoCmd RunSQL( "SELECT * FROM tContacts" )
it would become in OOoBase
Dim oStatement as variant oStatement = OForm.ActiveConnection.CreateStatement ' Where oForm is a DataForm object ' NOTE you could do exactly the same thing with ' a resultSet or rowSet obejct also ' oStatement = OResultSet.ActiveConnection.CreateStatement oStatement.execute( "SELECT * FROM ""tContacts""" )
If on the other hand the VBA line where
DoCmd RunSQL( "DELETE FROM tContacts WHERE Status = 'INACTIVE'" )
then we would use the executeUpdate method on a statement
oStatement.executeUpdate( "DELETE FROM ""tContacts"" WHERE ""Status"" = 'INACTIVE'" )
The rule is -
- if your SQL statement will return records you use execute or executeQuery.
- if the SQL statement returns no records then you must use executeUpdate.
If I use Lookup fields/columns in my Access tables what can I do in Base?
There are two parts to this answer, given that Base does not support Lookup column types in tables.
When a table is displayed in a custom form use of a bound listbox will give you the same functionality. An example of adding a listbox to a form and to a grid control on a form is at this page.
In a table view ( double clicking on the table name ) there is no equivalent to this.
How do I use Domain Aggregate functions in Base?
Domain Aggregate functions such as DCount, DLookup, DMax etc have no direct equivalent in Base. You will have to write or design queries to return these results using the appropriate SQL functions.
How do I add Calculated Controls to my forms and reports?
Controls in Base forms and reports cannot be used to perform calculations. There are two methods available to get a calculated result on a form or report.
Using a query
Modify the underlying data source of the form or report to perform the calculation for each record and return the result as a (calculated) field.
Using a macro
If you need your control to update as data is entered into a form, you will need to write a small macro to perform the calculation and assign it to an appropriate event on one of the data entry controls (e.g. the Text modified event).