Verify linked tables by code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi!

How can I verify if the linked tables are working well before I try to open
them?
I have one Macro that runs some queries. These queries works with linked
odbc tables. Sometimes, when the password for these linked tables changes, I
have to verify first if the linked tables are working well, or else my
application abort in the midle of the process.

Can you help me?
 
Hi Nuno !

Try this :

Function Attach_CheckAllAttachments() As Long

Dim Attach_DB As Database
Dim Attach_RS As Recordset
Dim Attach_I As Long
Dim lngRetVal As Long

#If ERR_ON Then
On Error GoTo Err_Attach_CheckAllAttachments
#End If

Set Attach_DB = CurrentDb
For Attach_I = 0 To Attach_DB.TableDefs.count - 1
If Len(Attach_DB.TableDefs(Attach_I).Connect) Then
Set Attach_RS =
Attach_DB.OpenRecordset(Attach_DB.TableDefs(Attach_I).Name, dbOpenSnapshot,
dbSeeChanges)
End If
Next Attach_I
lngRetVal = True

Exit_Attach_CheckAllAttachments:
Attach_CheckAllAttachments = lngRetVal
Exit Function

Err_Attach_CheckAllAttachments:
'
' Insert the routine to be processed when there is a problem with
' an attachment here.
'
lngRetVal = Err.Number
Resume Exit_Attach_CheckAllAttachments

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top