Searching through multiple databases

Prototype

Registered User.
Local time
Today, 13:19
Joined
Mar 26, 2017
Messages
11
Hello everyone,

Is there a way to search through multiple records/queries from different databases to see if there are duplicates?

Thanks so much.
 
if there is no linked table to your external database,
the one i can think of is (1) either open the other database
and open a recordset from table you want to search.
or (2) directly open a recordset from the external database.

Code:
(1)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim bolFound As Boolean

'open external db
Set db = OpenDatabase(CurrentProject.Path & "\ExternalDBname.accdb", False, False)

'open recordset based on what you like to find
Set rs = db.OpenRecordSet("Select * From ExternalTableName Where FieldInExternalTable = '" & yourSearchString & "'")

bolFound = (rs.BOF And rs.EOF)

'housekeeping
rs.Close
Set rs=Nothing
Set db=Nothing
Code:
(2)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim bolFound As Boolean

Set db=CurrentDB
'open recordset based on what you like to find
Set rs = db.OpenRecordSet("Select * From " & _
			ExternalTableName  & _
			" In '" & _
			CurrentProjectPath & "\" & _
			"ExternalWhereDBName & "' Where FieldInExternalTable = '" & yourSearchString & "'")
bolFound = (rs.BOF And rs.EOF)

'housekeeping
rs.Close
Set rs=Nothing
Set db=Nothing
 

Users who are viewing this thread

Back
Top Bottom