J
j_gold
Hi,
I've been trying to figure out how to use the seek method on a linked table.
I've found a few
links here and there that reference how to do it, and I copied the one from
MS
(http://support.microsoft.com/kb/210266/) that shows a workaround. I've
copied the code used below.
I have been unsuccessful at getting it to work. I'm getting error: 3024
could not find file People;. People is a linked MySQL database that I set up
as a user DSN connection.
I am not sure what I need to do to get this to work, any and all suggestions
appreciated.
Cheers, J
Code use as supplied by MS:
Sub Seek_Attached_Table(Tablename, Indexname, SearchValue)
Dim db As Database
Dim t As TableDef
Dim rs As DAO.Recordset
Dim dbpath, SourceTable
On Error GoTo SA_Errors
Set db = DBEngine(0)(0)
dbpath = Mid(db(Tablename).connect, InStr(1, _
db(Tablename).connect, "=") + 1)
If dbpath = "" Then MsgBox "You've chosen a table already in the current
database", 64, "": Exit Sub
SourceTable = db(Tablename).SourceTableName
Set db = DBEngine(0).openDatabase(dbpath)
Set rs = db.OpenRecordset(SourceTable, DB_OPEN_TABLE)
rs.Index = Indexname
rs.Seek "=", SearchValue
If Not rs.NoMatch Then
MsgBox "Found It!", 64
Else
MsgBox "Not Found", 64
End If
rs.Close
db.Close
Exit Sub
SA_Errors:
MsgBox Error, 16, CStr(Err)
Exit Sub
End Sub
MS Code:
Sub Seek_Attached_Table(Tablename, Indexname, SearchValue)
Dim db As Database
Dim t As TableDef
Dim rs As DAO.Recordset
Dim dbpath, SourceTable
On Error GoTo SA_Errors
Set db = DBEngine(0)(0)
dbpath = Mid(db(Tablename).connect, InStr(1, _
db(Tablename).connect, "=") + 1)
If dbpath = "" Then MsgBox "You've chosen a table already in the current
database", 64, "": Exit Sub
SourceTable = db(Tablename).SourceTableName
Set db = DBEngine(0).openDatabase(dbpath)
Set rs = db.OpenRecordset(SourceTable, DB_OPEN_TABLE)
rs.Index = Indexname
rs.Seek "=", SearchValue
If Not rs.NoMatch Then
MsgBox "Found It!", 64
Else
MsgBox "Not Found", 64
End If
rs.Close
db.Close
Exit Sub
SA_Errors:
MsgBox Error, 16, CStr(Err)
Exit Sub
End Sub
I've been trying to figure out how to use the seek method on a linked table.
I've found a few
links here and there that reference how to do it, and I copied the one from
MS
(http://support.microsoft.com/kb/210266/) that shows a workaround. I've
copied the code used below.
I have been unsuccessful at getting it to work. I'm getting error: 3024
could not find file People;. People is a linked MySQL database that I set up
as a user DSN connection.
I am not sure what I need to do to get this to work, any and all suggestions
appreciated.
Cheers, J
Code use as supplied by MS:
Sub Seek_Attached_Table(Tablename, Indexname, SearchValue)
Dim db As Database
Dim t As TableDef
Dim rs As DAO.Recordset
Dim dbpath, SourceTable
On Error GoTo SA_Errors
Set db = DBEngine(0)(0)
dbpath = Mid(db(Tablename).connect, InStr(1, _
db(Tablename).connect, "=") + 1)
If dbpath = "" Then MsgBox "You've chosen a table already in the current
database", 64, "": Exit Sub
SourceTable = db(Tablename).SourceTableName
Set db = DBEngine(0).openDatabase(dbpath)
Set rs = db.OpenRecordset(SourceTable, DB_OPEN_TABLE)
rs.Index = Indexname
rs.Seek "=", SearchValue
If Not rs.NoMatch Then
MsgBox "Found It!", 64
Else
MsgBox "Not Found", 64
End If
rs.Close
db.Close
Exit Sub
SA_Errors:
MsgBox Error, 16, CStr(Err)
Exit Sub
End Sub
MS Code:
Sub Seek_Attached_Table(Tablename, Indexname, SearchValue)
Dim db As Database
Dim t As TableDef
Dim rs As DAO.Recordset
Dim dbpath, SourceTable
On Error GoTo SA_Errors
Set db = DBEngine(0)(0)
dbpath = Mid(db(Tablename).connect, InStr(1, _
db(Tablename).connect, "=") + 1)
If dbpath = "" Then MsgBox "You've chosen a table already in the current
database", 64, "": Exit Sub
SourceTable = db(Tablename).SourceTableName
Set db = DBEngine(0).openDatabase(dbpath)
Set rs = db.OpenRecordset(SourceTable, DB_OPEN_TABLE)
rs.Index = Indexname
rs.Seek "=", SearchValue
If Not rs.NoMatch Then
MsgBox "Found It!", 64
Else
MsgBox "Not Found", 64
End If
rs.Close
db.Close
Exit Sub
SA_Errors:
MsgBox Error, 16, CStr(Err)
Exit Sub
End Sub