E
Edwinah63
i have an access 2000 db in which i dynamically relink the tables from
sqlserver 2000 depending on the user - some users having read only
permissions, others read/write etc.
however access 2000 DOES NOT relink correctly and after looking in
msysobjects in access, have found that it seems to cache the last login
name. needless to say this ruins any permissions i have set on
sqlserver.
an edit of the code is attached below:
step 1. delete attached tables - this works and clears out msysobjects
step 2. get tablenames from sql server as recordset - this works as
well.
step 3. reattach
ODBC_STR = "ODBC;DSN=BMTL;DATABASE=BMTL;UID=" & Usr & ";PWD=;"
Set dbsODBC = OpenDatabase("", False, False, ODBC_STR)
'rs(0) = tablename
Do While Not rs.EOF
Set td = CurrentDb.CreateTableDef(rs(0), dbAttachSavePWD)
td.Connect = dbsODBC.Connect
td.SourceTableName = dbsODBC.TableDefs("dbo." & rs(0)).Name
CurrentDb.TableDefs.Append td
CurrentDb.TableDefs.Refresh 'refresh link here hopefully
rs.MoveNext
Loop
'refresh just to be sure
CurrentDb.TableDefs.Refresh
'open msysobjects in access and all are linked on either the current
login or on some previously cached login - which it does is random.
is there some attribute or method i can call that will absolutely
refresh the odbc link on the table???
regards
Edwinah63
sqlserver 2000 depending on the user - some users having read only
permissions, others read/write etc.
however access 2000 DOES NOT relink correctly and after looking in
msysobjects in access, have found that it seems to cache the last login
name. needless to say this ruins any permissions i have set on
sqlserver.
an edit of the code is attached below:
step 1. delete attached tables - this works and clears out msysobjects
step 2. get tablenames from sql server as recordset - this works as
well.
step 3. reattach
ODBC_STR = "ODBC;DSN=BMTL;DATABASE=BMTL;UID=" & Usr & ";PWD=;"
Set dbsODBC = OpenDatabase("", False, False, ODBC_STR)
'rs(0) = tablename
Do While Not rs.EOF
Set td = CurrentDb.CreateTableDef(rs(0), dbAttachSavePWD)
td.Connect = dbsODBC.Connect
td.SourceTableName = dbsODBC.TableDefs("dbo." & rs(0)).Name
CurrentDb.TableDefs.Append td
CurrentDb.TableDefs.Refresh 'refresh link here hopefully
rs.MoveNext
Loop
'refresh just to be sure
CurrentDb.TableDefs.Refresh
'open msysobjects in access and all are linked on either the current
login or on some previously cached login - which it does is random.
is there some attribute or method i can call that will absolutely
refresh the odbc link on the table???
regards
Edwinah63