Function OpenAccessConnection LParameters tcMdb, tcID, tcPwd && path to access mdb, ID and Password Local loRetVal, lcDir, lcDatabase, lcConnString #Include 'adovfp.h' If PCount() < 3 tcPwd = '' endif If PCount() < 2 tcId = '' Endif lcDir = JustPath(tcMdb) && find path to MDB lcDatabase = JustStem(tcMdb) && separate out the mdb name If !Empty(lcDatabase) And (PCOUNT() = 3) lcConnString = "Driver={Microsoft Access Driver (*.mdb)};DefaultDir=" + lcDir + ; ";DBQ=" + lcDatabase + ; ";User Id=" + tcID + ; ";Password=" + tcPwd loRetVal = CreateObject('ADODB.Connection') loRetVal.Open(lcConnString) Else loRetVal = .NULL. Endif Return loRetVal Function OpenAccessTable LParameters toConnection, tcTable, tcHow, tcWhere && connection object from above, * tablename or select statement , * how to connect (optimistic etc., cursor location (server or client) Local loRetVal, lnHow, lnWhere, lcOpenString #Include 'adovfp.h' If PCount() < 4 lnWhere = adUseClient Else If Upper(Alltrim(tcWhere)) = 'SERVER' lnWhere = adUseServer Else lnWhere = adUseClient Endif Endif * default to readonly If PCount() < 3 lnHow = adLockReadOnly Else Do Case Case Upper(Alltrim(tcHow)) = 'OPTIMISTIC' lnHow = adLockOptimistic Case Upper(Alltrim(tcHow)) = 'PESSIMISTIC' lnHow = adLockPessimistic Case Upper(Alltrim(tcHow)) = 'BATCH' lnHow = adLockBatchOptimistic Otherwise lnHow = adLockReadOnly EndCase Endif loRetVal = .Null. && return null if this doesn't work If (PCount() >= 2) And !IsNull(toConnection) And !Empty(tcTable) If toConnection.State = adStateOpen * create open string using a select - either sent in, or created here lcOpenString = IIF('SELECT ' $ upper(tcTable), ; Alltrim(tcTable), 'Select * from ' + Alltrim(tcTable)) loRetVal = CreateObject('ADODB.RecordSet') loRetVal.CursorLocation = llnWhere loRetVal.Open(cOpenString, toConnection, adOpenStatic, lnHow, adFetchAsync + adCmdText) Endif Endif Return loRetVal