'*******Global database reference variable****** Private LDatabase As Database ''************************************************************** 'Routine to open a Jet database, given the path to the mdb database ''************************************************************** Public Sub GDBOpen(ByVal dbname As String) On Error Resume Next Set LDatabase = OpenDatabase(dbname) If LDatabase Is Nothing Then MsgBox "Unable to open db " & dbname End If End Sub ''********************** Close Batabase***************** Public Sub GDbClose() On Error Resume Next LDatabase.Close End Sub '*********Routine to execute delete, update, insert******** Public Function GDBExecute(ByVal sql As String) As Boolean On Error GoTo ErrorHandler GDBExecute = False LDatabase.Execute (sql) GDBExecute = True Exit Sub ErrorHandler: LError End Function '******** Error handler for DAO update routine********* Private Sub LError() Dim str As String If Err.Number <> 0 Then str = Err.Description & vbCrLf Dim i As Integer For i = 0 To DAO.Errors.Count - 1 str = str & DAO.Errors(i).Description & vbCrLf & DAO.Errors(i).Source Next MsgBox str End Sub '**************Routine to open a record set**************** Function GDBRecordset(ByVal sql As String) As Recordset On Error Resume Next Set GDBRecordset = LDatabase.OpenRecordset(sql) End Function '*****************Return the first field ************** Function GDBQuery(ByVal sql As String) As String On Error Resume Next Dim rs As Recordset Set rs = GDBRecordset(sql) GDBQuery = str(rs.Fields(0)) End Function