REM ***** BASIC ***** REM ***** BASIC ***** Sub OpenMainMenu Dim DatabaseContext as Object Dim DataSource as Object Dim Doc as Object Dim Form as Object Dim oFormDoc as Object Dim Forms Dim oParms(1) As New com.sun.star.beans.PropertyValue Dim I as Integer Dim names Dim dbExists as Boolean Dim subjectDb Dim oCon as Object subjectDb="amhcc" 'First look up the registered databases DatabaseContext = createUnoService("com.sun.star.sdb.DatabaseContext") Names=DatabaseContext.getElementNames() dbExists=FALSE 'Now check to make sure the one we want is there. For I = 0 To UBound(Names()) If names(I)=subjectDb Then dbExists=TRUE EndIf Next If dbExists=True then ' msgbox("Database " & subjectDb & " Found") Else msgbox("Error: Unable to locate " & subjectDb & " Database") Exit Sub Endif 'Now go to that database and open the form we expect to be there ON Error GOTO OpenPhoneBookError DataSource=DatabaseContext.getByName(subjectDb) Doc=DataSource.DatabaseDocument Forms=Doc.GetFormDocuments Form=Forms.getByName("MainMenu") oCon = DataSource.getConnection("", "") oParms(0).Name = "ActiveConnection" oParms(0).Value = oCon oParms(1).Name = "OpenMode" oParms(1).Value = "open" oFormDoc = Forms.loadComponentFromURL("MainMenu", "", 0, oParms()) Exit Sub OpenPhoneBookError: msgbox("Error Occurred"& Err & Error$ & Erl ) On Error Goto 0 End Sub