Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.
Public Sub Init() 'Called by OPEN FORM event On Error GoTo Check_Err Dim rs As DAO.Recordset Set dbCurrent = CurrentDb() ' First try to connect using SQL Native Client driver Native_Fail = False FMRdsn = "LCOG_FMR_ODBC_NATIVE" Set rs = dbCurrent.OpenRecordset(FMRdsn, dbOpenDynaset, dbSeeChanges) 'If driver unavailable, generates error 3151 Set rs = Nothing 'close recordset Exit Sub Native_No: ' If native driver unavailable, try to connect using MDAC ODBC driver FMRdsn = "LCOG_FMR_MDAC_ODBC" Set rs = dbCurrent.OpenRecordset(FMRdsn, dbOpenDynaset, dbSeeChanges) 'If driver unavailable, generates error 3151 Set rs = Nothing 'close recordset Exit Sub Check_Err: Select Case Err.Number Case 3151 'Unable to connect using an ODBC driver If FMRdsn = "LCOG_FMR_ODBC_NATIVE" Then Native_Fail = True 'Native Client didn't work, try MDAC Resume Native_No ElseIf Native_Fail Then 'Both MDAC and SQL Native Client ODBC driver connections failed. MsgBox ("Cannot connect to LCOG SQL database, check ODBC drivers - switching to local database"), _ vbOKOnly + vbCritical, "Cannot connect to LCOG SQL database (Error #" & Err.Number & ")" FMRdsn = "local_FMR" End If Case Else MsgBox Err.Description & " (" & Err.Number & ")", vbOKOnly + vbCritical, "Error" If Not IsAdmin Then Application.Quit End Select Set rs = Nothing 'close recordset End Sub
|I suddenly cannot write to C drive||20||71|
|How to run a VBS file in a MS access macro?||2||27|
|Solved: How can I prevent deletions from a form in datasheet view?||5||25|
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
8 Experts available now in Live!