My goal is to see if I can open a table that is linked to another Access database so that I can test to make sure that the connection does exist and doesn't need reconnected to a different BE or just another location. It was suggested to first check if the file existed where I thought it should be and then see if I can open the recordset. If both come back true, then I'm good. Otherwise if one comes back false, then I need to reconnect to the BE. I have the code to test if the file exists and I now just need to figure out how to see if I can open the recordset.
Well, my stab at opening the recordset and trapping the error didn't work too well. I tried copying what MSDN had here, but I'm getting a Run-time error 3219: Invalid Operation on line 8 for some reason. Here is what I have:
Line #5 is commented out so that I can see what the error is since otherwise it just skips to line #12. strDBName = tblTest which is the only table that I currently have in this test database (the name is correct).
Well, my stab at opening the recordset and trapping the error didn't work too well. I tried copying what MSDN had here, but I'm getting a Run-time error 3219: Invalid Operation on line 8 for some reason. Here is what I have:
Code:
Public Function Connected(strDBName As String) As Boolean Dim db As DAO.Database Dim rsTable As DAO.Recordset 'On Error GoTo Err_SetValue Set db = CurrentDb Set rsTable = db.OpenRecordset(strDBName, dbOpenTable) Connected = True Err_SetValue: Connected = False End Function
Comment