J
Jeff Gobatto
OK two completely independent problems (different
projects) but I thought I'd post them together.
#1: Exclusive Access
I have a Sub that I call to link a table. The code is
pasted below:
Sub LinkOneTable(strSourceFile As String, strSourceTable
As String, strDestTable As String)
Dim tdfMain As TableDef
Dim intIdx As Integer
Set tdfMain = CurrentDb.CreateTableDef(strDestTable)
tdfMain.Connect = "MS Access;PWD=;DATABASE=" &
strSourceFile
tdfMain.SourceTableName = strSourceTable
tdfMain.Attributes = dbAttachExclusive
CurrentDb.TableDefs.Append tdfMain
CurrentDb.TableDefs.Refresh
Set tdfMain = Nothing
End Sub
I'm using DAO 3.6
The code works (I link the table). The problem is, if I
try to edit any existing code in the MDB file after I run
it (i.e. any module, even ones without this sub in it) I
get the following message as soon as I try to type (hard
return, space, character, whatever) in the VBA editor
window:
"You do not have exclusive access to the database at this
time. If you proceed to make changes, you may not be
able to save them later."
The message box only has an OK button, so I couldn't
search Access help.
If someone can see the error in the above sub, please let
me know.
#2: Recordset Objects
I recently migrated from Office 97 to XP, and one thing I
found was that I get a Type Mismatch error (13) at
runtime when I try to use the following:
Set rstTemp = CurrentDb.OpenRecordset("select * from
tblMyTable")
and I have declared rstTemp as Recordset. If I declare
it without a type (i.e. as a variant) then everything is
fine.
Again, I've got DAO 3.6 referenced.
Can anyone explain why this is, and if there's a way to
declare a recordset object AND use the OpenRecordset
method successfully?
Thanks in advance for any assistance.
J.
projects) but I thought I'd post them together.
#1: Exclusive Access
I have a Sub that I call to link a table. The code is
pasted below:
Sub LinkOneTable(strSourceFile As String, strSourceTable
As String, strDestTable As String)
Dim tdfMain As TableDef
Dim intIdx As Integer
Set tdfMain = CurrentDb.CreateTableDef(strDestTable)
tdfMain.Connect = "MS Access;PWD=;DATABASE=" &
strSourceFile
tdfMain.SourceTableName = strSourceTable
tdfMain.Attributes = dbAttachExclusive
CurrentDb.TableDefs.Append tdfMain
CurrentDb.TableDefs.Refresh
Set tdfMain = Nothing
End Sub
I'm using DAO 3.6
The code works (I link the table). The problem is, if I
try to edit any existing code in the MDB file after I run
it (i.e. any module, even ones without this sub in it) I
get the following message as soon as I try to type (hard
return, space, character, whatever) in the VBA editor
window:
"You do not have exclusive access to the database at this
time. If you proceed to make changes, you may not be
able to save them later."
The message box only has an OK button, so I couldn't
search Access help.
If someone can see the error in the above sub, please let
me know.
#2: Recordset Objects
I recently migrated from Office 97 to XP, and one thing I
found was that I get a Type Mismatch error (13) at
runtime when I try to use the following:
Set rstTemp = CurrentDb.OpenRecordset("select * from
tblMyTable")
and I have declared rstTemp as Recordset. If I declare
it without a type (i.e. as a variant) then everything is
fine.
Again, I've got DAO 3.6 referenced.
Can anyone explain why this is, and if there's a way to
declare a recordset object AND use the OpenRecordset
method successfully?
Thanks in advance for any assistance.
J.