MSA-Base Faq
Common questions and answers for those migrating from Microsoft Access (MSA) to OpenOffice.org Base.
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 )
For asking specific questions or for general help it would be appropriate to then ask on either the: Base Forum or on the Base users mailing list.
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 an Open Document Base file (*.odb), which holds the connection information. For details see Microsoft Access or Connecting to Microsoft Access.
You can modify the data in the tables and you can add and remove records. You can create new tables, but you cannot alter the structure of existing tables.
Queries in MS Access are shown as views in the table container. You can use the query results, but you have no access to the underlying definitions and you cannot alter them.
You cannot read MS Access forms or reports.
Can I read my Base database from MS Access (MSA)?
That depends. There's no way to use the table linking mechanism in MSA to connect to an "embedded database" stored within a Base .odb file. It is possible to extract the (native HSQLDB) database files manually (step-by-step) from a Base .odb file, for indirect access through the "JDBC" driver/engine bundled with OpenOffice.org (hsqldb.jar). This can be a preferred configuration with Base to ensure data durability. However, MS Access doesn't offer JDBC linking, so a third-party ODBC-to-JDBC "bridge" or "gateway" (diagram) would be required to connect to the extracted database files. Another approach involves further database migration to an RDBMS offering "ODBC" connectivity. Simply upgrading Base to HSQLDB 2.x is not the immediate solution for MSA linking because the necessary "ODBC" option is still under development. But there's plenty of ODBC-compatible options for Base/MSA, including SQL Server Express, H2 (tutorial), SQLite, PostgreSQL, MySQL, MariaDB, Firebird, MS SQL Server, Oracle, etc.
It is possible to use a Base .odb file to update data in an Access database (.mdb) on a Windows machine. This requires 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 cannot create a new Access database file; or new tables; or modify existing table structures/properties. Base queries, forms and reports can be added to the Base .odb file, but not to the Access .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 one of several techniques.
Opening a default form via a macro
Using a stand alone form to launch the Base database
see Tutorial: Standalone Forms / Switchboard
Base Switchboard extension
Development started to bring switchboard feature into OOo, see the Roberto Benitez's Base Switchboard extension.
Our MS Access (MSA) databases uses "Workgroup Security" to control group/user permission to view/maintain data. Is similar access control and security possible with Base?
This question highlights some fundamental differences between Base and MS Access (MSA). Traditionally, the integral Jet/ACE engine was involved in database security -- including linked data-sources. This has been a problem for MSA developers because the all-in-one MDB/ACCDB file supports either "workgroup" (access control) or "security" (encryption) functions but not both. Of course, effective "database security" involves both functions. Specifically, the Jet-MDB database format (MSA 2003 and earlier) is not truly "secure" but it does offer "workgroup" (access control) functions including individual user-login and user/group permissions. On the other hand, the ACE-ACCDB file format (MSA 2007) is relatively "secure" (encryption) but forgoes the "workgroup" function in favor of a single login. MSA 2010 rectifies the situation by offering to 'split the database' into front-end and back-end files. This allows database security to be handled by the back-end database engine, just as it is with Base. And like Base, you'll need to jettison the built-in Jet/ACE back-end, using only the MDB/ACCDB front-end to link to a full-featured database engine, in order to achieve true database security with MSA. Microsoft has even depreciated "Workgroup Security" in MSA 2010, but continues to support the legacy function of the Jet engine for MDB files created with MSA 2003 or earlier. So in the end, MSA's "Workgroup Security" feature was largely an oxymoron.
In Base, all multi-user databases are "split." The Base 'user authentication' feature could use some improvements, but Base is simply a front-end (client application) to a variety of database engines. The engines, themselves, provide various levels of database security from none with dBase files or SQLite; to role based access control (RBAC) using the built-in HSQLDB engine; to both RBAC and database encryption in more advanced engines.
Base's bundled HSQLDB engine is similar to MSA's Jet/ACE engine in terms of multi-user function. Like alternative engines, HSQLDB must be run in server mode in support of multiple users. This engine supports 'role based access control' similar to the Jet-MDB "workgroup" function. Security is likewise limited. Otherwise, the primary role of the built-in HSQLDB engine is in support of the "embedded database" configuration which 'embeds' the database data inside the Base ODB container file, similar to an MSA file. This all-in-one ODB file is often referred to as a "Base database." But unlike MSA, this particular Base file is single-user and more easily corrupted, so these all-in-one ODB files are not recommended beyond database-prototyping and examples. A production database should always be deployed in a 'split' configuration using an ODB file generated by the "Connect to an existing database" wizard. In a split-configuration, no back-end database data is stored within the Base ODB file. Only front-end components such as Base Queries, Forms, Reports and Macros are stored therein. This is very similar to the 'split database' function in MSA 2010.
For comprehensive database security with Base, including encryption, consider HSQLDB 2.x, H2, Apache Derby, PostgreSQL 9.1 or later, Oracle with the Advanced Security option, and of course MS SQL Server 2008 or later with TDE. If you're supporting a very large number of users select the latter: PostgreSQL, Oracle, or MS SQL Server.
There are some considerations when deploying Base or MSA in multi-user environments. In MSA, you generally provide shared access to a single MDB/ACCDB file. In MSA 2010, you can split the ACCDB file to separate front-end and back-end functions, similar to the requisite 'existing database' configuration with Base. This split configuration allows you to share the front-end files (MDB/ACCDB/ODB) file for common access to front-end Queries, Forms, Reports and Macros, in addition to multi-user access to the back-end database. These split functions also allow the distribution of individual copies of the front-end (MDB/ACCDB/ODB) in support of personalized Queries, Forms, etc. while maintaining common access to the database(s).
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
Virtual forms in Base are called "subforms". You can manage them opening the form in Edit mode and then clicking on "Form Navigator", in "Form Design" toolbar.
Where are the Delete / Update queries?
Base does not currently support building delete / insert / update queries in the designer.
Equivalent actions
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 pseudo 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 pseudo variable thisComponent normally would be the TextDocument, while thisComponent.DrawPage.Forms(0) meanwhile would reference the first DataForm owned by the TextDocument.
Perhaps a still closer equivalent 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).
Autor: MSA-Base Faq Drew 21:01, 11 September 2007 (CEST) '
Please do not change the logical content of this site without
acknowledge of the author or the OOo QA Project Lead/Co-Leads.