Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT
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
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.