Forcing Access to forget a username and password for a linked table
I have an MS Access database that is connected to SQL server via linked servers.
The linked tables are added using a modified AttachDSNLessTable
procedure:
stConnect = "ODBC;DRIVER=" & stDriverName & ";SERVER=" & stServer & ";DATABASE=" & stDatabase & ";UID=" & stUsername & ";PWD=" & stPassword
Set td = CurrentDb.CreateTableDef(stLocalTableName)
td.SourceTableName = stRemoteTableName
td.Connect = stConnect
CurrentDb.TableDefs.Append td
I have a facility within the application to change the logged in user, this will remove all the tabledefs:
For Each td In CurrentDb.TableDefs
If td.Name = stLocalTableName Then
CurrentDb.TableDefs.Delete stLocalTableName
End If
Next
Then it will re-add using the procedure above.
Now this appears to work however if I log in as user1
then change user to user2
without closing Access the connection is made using the user1
credentials, running a view that includes SUSER_NAME()
shows user1
is the logged in user.
Is there any way to force the connection to be reset or to force the user to be changed?
Edit
My entire login function:
Function AttachDSNLessTable(stLocalTableName As String, stRemoteTableName As String, stDriverName As String, stServer As String, stDatabase As String, Optional stUsername As String, Optional stPassword As String)
On Error GoTo AttachDSNLessTable_Err
Dim td As TableDef
Dim stConnect As String
For Each td In CurrentDb.TableDefs
If td.Name = stLocalTableName Then
CurrentDb.TableDefs.Delete stLocalTableName
Exit For
End If
Next
If Len(stUsername) = 0 Then
'//Use trusted authentication if stUsername is not supplied.
stConnect = "ODBC;DRIVER=" & stDriverName & ";SERVER=" & stServer & ";DATABASE=" & stDatabase & ";Trusted_Connection=Yes"
Else
'//WARNING: This will save the username and the password with the linked table information.
stConnect = "ODBC;DRIVER=" & stDriverName & ";SERVER=" & stServer & ";DATABASE=" & stDatabase & ";UID=" & stUsername & ";PWD=" & stPassword
End If
Set td = CurrentDb.CreateTableDef(stLocalTableName)
td.SourceTableName = stRemoteTableName
td.Connect = stConnect
CurrentDb.TableDefs.Append td
AttachDSNLessTable = ""
Exit Function
AttachDSNLessTable_Err:
AttachDSNLessTable = err.Description
End Function
sql-server vba ms-access azure-sql-database
|
show 13 more comments
I have an MS Access database that is connected to SQL server via linked servers.
The linked tables are added using a modified AttachDSNLessTable
procedure:
stConnect = "ODBC;DRIVER=" & stDriverName & ";SERVER=" & stServer & ";DATABASE=" & stDatabase & ";UID=" & stUsername & ";PWD=" & stPassword
Set td = CurrentDb.CreateTableDef(stLocalTableName)
td.SourceTableName = stRemoteTableName
td.Connect = stConnect
CurrentDb.TableDefs.Append td
I have a facility within the application to change the logged in user, this will remove all the tabledefs:
For Each td In CurrentDb.TableDefs
If td.Name = stLocalTableName Then
CurrentDb.TableDefs.Delete stLocalTableName
End If
Next
Then it will re-add using the procedure above.
Now this appears to work however if I log in as user1
then change user to user2
without closing Access the connection is made using the user1
credentials, running a view that includes SUSER_NAME()
shows user1
is the logged in user.
Is there any way to force the connection to be reset or to force the user to be changed?
Edit
My entire login function:
Function AttachDSNLessTable(stLocalTableName As String, stRemoteTableName As String, stDriverName As String, stServer As String, stDatabase As String, Optional stUsername As String, Optional stPassword As String)
On Error GoTo AttachDSNLessTable_Err
Dim td As TableDef
Dim stConnect As String
For Each td In CurrentDb.TableDefs
If td.Name = stLocalTableName Then
CurrentDb.TableDefs.Delete stLocalTableName
Exit For
End If
Next
If Len(stUsername) = 0 Then
'//Use trusted authentication if stUsername is not supplied.
stConnect = "ODBC;DRIVER=" & stDriverName & ";SERVER=" & stServer & ";DATABASE=" & stDatabase & ";Trusted_Connection=Yes"
Else
'//WARNING: This will save the username and the password with the linked table information.
stConnect = "ODBC;DRIVER=" & stDriverName & ";SERVER=" & stServer & ";DATABASE=" & stDatabase & ";UID=" & stUsername & ";PWD=" & stPassword
End If
Set td = CurrentDb.CreateTableDef(stLocalTableName)
td.SourceTableName = stRemoteTableName
td.Connect = stConnect
CurrentDb.TableDefs.Append td
AttachDSNLessTable = ""
Exit Function
AttachDSNLessTable_Err:
AttachDSNLessTable = err.Description
End Function
sql-server vba ms-access azure-sql-database
@AndyG There is a 'Change User' option ont he Navigation panel, this re-opens the login form. When the user logs in it removes the tabledef objects using the second block of code and re-adds them using the new User/Pass however it's actually opening the connection using the original user/pass.
– bendataclear
Nov 15 '18 at 10:29
Also, is a general user able to use this facility? Should they be able to switch username without first exiting?
– Andy G
Nov 15 '18 at 10:29
@AndyG Yes it's available for any user.
– bendataclear
Nov 15 '18 at 10:31
Access is a poor fit for this, but, in my opinion, your general User / Joe should not be able to switch user without exiting Access. Otherwise, as mentioned, it is during the process of changing user that the connection can be reset.
– Andy G
Nov 15 '18 at 10:32
@AndyG I agree, Access is a poor fit but it's not possible to change it. Do you know how to reset the connection?
– bendataclear
Nov 15 '18 at 10:35
|
show 13 more comments
I have an MS Access database that is connected to SQL server via linked servers.
The linked tables are added using a modified AttachDSNLessTable
procedure:
stConnect = "ODBC;DRIVER=" & stDriverName & ";SERVER=" & stServer & ";DATABASE=" & stDatabase & ";UID=" & stUsername & ";PWD=" & stPassword
Set td = CurrentDb.CreateTableDef(stLocalTableName)
td.SourceTableName = stRemoteTableName
td.Connect = stConnect
CurrentDb.TableDefs.Append td
I have a facility within the application to change the logged in user, this will remove all the tabledefs:
For Each td In CurrentDb.TableDefs
If td.Name = stLocalTableName Then
CurrentDb.TableDefs.Delete stLocalTableName
End If
Next
Then it will re-add using the procedure above.
Now this appears to work however if I log in as user1
then change user to user2
without closing Access the connection is made using the user1
credentials, running a view that includes SUSER_NAME()
shows user1
is the logged in user.
Is there any way to force the connection to be reset or to force the user to be changed?
Edit
My entire login function:
Function AttachDSNLessTable(stLocalTableName As String, stRemoteTableName As String, stDriverName As String, stServer As String, stDatabase As String, Optional stUsername As String, Optional stPassword As String)
On Error GoTo AttachDSNLessTable_Err
Dim td As TableDef
Dim stConnect As String
For Each td In CurrentDb.TableDefs
If td.Name = stLocalTableName Then
CurrentDb.TableDefs.Delete stLocalTableName
Exit For
End If
Next
If Len(stUsername) = 0 Then
'//Use trusted authentication if stUsername is not supplied.
stConnect = "ODBC;DRIVER=" & stDriverName & ";SERVER=" & stServer & ";DATABASE=" & stDatabase & ";Trusted_Connection=Yes"
Else
'//WARNING: This will save the username and the password with the linked table information.
stConnect = "ODBC;DRIVER=" & stDriverName & ";SERVER=" & stServer & ";DATABASE=" & stDatabase & ";UID=" & stUsername & ";PWD=" & stPassword
End If
Set td = CurrentDb.CreateTableDef(stLocalTableName)
td.SourceTableName = stRemoteTableName
td.Connect = stConnect
CurrentDb.TableDefs.Append td
AttachDSNLessTable = ""
Exit Function
AttachDSNLessTable_Err:
AttachDSNLessTable = err.Description
End Function
sql-server vba ms-access azure-sql-database
I have an MS Access database that is connected to SQL server via linked servers.
The linked tables are added using a modified AttachDSNLessTable
procedure:
stConnect = "ODBC;DRIVER=" & stDriverName & ";SERVER=" & stServer & ";DATABASE=" & stDatabase & ";UID=" & stUsername & ";PWD=" & stPassword
Set td = CurrentDb.CreateTableDef(stLocalTableName)
td.SourceTableName = stRemoteTableName
td.Connect = stConnect
CurrentDb.TableDefs.Append td
I have a facility within the application to change the logged in user, this will remove all the tabledefs:
For Each td In CurrentDb.TableDefs
If td.Name = stLocalTableName Then
CurrentDb.TableDefs.Delete stLocalTableName
End If
Next
Then it will re-add using the procedure above.
Now this appears to work however if I log in as user1
then change user to user2
without closing Access the connection is made using the user1
credentials, running a view that includes SUSER_NAME()
shows user1
is the logged in user.
Is there any way to force the connection to be reset or to force the user to be changed?
Edit
My entire login function:
Function AttachDSNLessTable(stLocalTableName As String, stRemoteTableName As String, stDriverName As String, stServer As String, stDatabase As String, Optional stUsername As String, Optional stPassword As String)
On Error GoTo AttachDSNLessTable_Err
Dim td As TableDef
Dim stConnect As String
For Each td In CurrentDb.TableDefs
If td.Name = stLocalTableName Then
CurrentDb.TableDefs.Delete stLocalTableName
Exit For
End If
Next
If Len(stUsername) = 0 Then
'//Use trusted authentication if stUsername is not supplied.
stConnect = "ODBC;DRIVER=" & stDriverName & ";SERVER=" & stServer & ";DATABASE=" & stDatabase & ";Trusted_Connection=Yes"
Else
'//WARNING: This will save the username and the password with the linked table information.
stConnect = "ODBC;DRIVER=" & stDriverName & ";SERVER=" & stServer & ";DATABASE=" & stDatabase & ";UID=" & stUsername & ";PWD=" & stPassword
End If
Set td = CurrentDb.CreateTableDef(stLocalTableName)
td.SourceTableName = stRemoteTableName
td.Connect = stConnect
CurrentDb.TableDefs.Append td
AttachDSNLessTable = ""
Exit Function
AttachDSNLessTable_Err:
AttachDSNLessTable = err.Description
End Function
sql-server vba ms-access azure-sql-database
sql-server vba ms-access azure-sql-database
edited Nov 15 '18 at 19:27
Parfait
52.7k94471
52.7k94471
asked Nov 15 '18 at 10:15
bendataclearbendataclear
3,00031941
3,00031941
@AndyG There is a 'Change User' option ont he Navigation panel, this re-opens the login form. When the user logs in it removes the tabledef objects using the second block of code and re-adds them using the new User/Pass however it's actually opening the connection using the original user/pass.
– bendataclear
Nov 15 '18 at 10:29
Also, is a general user able to use this facility? Should they be able to switch username without first exiting?
– Andy G
Nov 15 '18 at 10:29
@AndyG Yes it's available for any user.
– bendataclear
Nov 15 '18 at 10:31
Access is a poor fit for this, but, in my opinion, your general User / Joe should not be able to switch user without exiting Access. Otherwise, as mentioned, it is during the process of changing user that the connection can be reset.
– Andy G
Nov 15 '18 at 10:32
@AndyG I agree, Access is a poor fit but it's not possible to change it. Do you know how to reset the connection?
– bendataclear
Nov 15 '18 at 10:35
|
show 13 more comments
@AndyG There is a 'Change User' option ont he Navigation panel, this re-opens the login form. When the user logs in it removes the tabledef objects using the second block of code and re-adds them using the new User/Pass however it's actually opening the connection using the original user/pass.
– bendataclear
Nov 15 '18 at 10:29
Also, is a general user able to use this facility? Should they be able to switch username without first exiting?
– Andy G
Nov 15 '18 at 10:29
@AndyG Yes it's available for any user.
– bendataclear
Nov 15 '18 at 10:31
Access is a poor fit for this, but, in my opinion, your general User / Joe should not be able to switch user without exiting Access. Otherwise, as mentioned, it is during the process of changing user that the connection can be reset.
– Andy G
Nov 15 '18 at 10:32
@AndyG I agree, Access is a poor fit but it's not possible to change it. Do you know how to reset the connection?
– bendataclear
Nov 15 '18 at 10:35
@AndyG There is a 'Change User' option ont he Navigation panel, this re-opens the login form. When the user logs in it removes the tabledef objects using the second block of code and re-adds them using the new User/Pass however it's actually opening the connection using the original user/pass.
– bendataclear
Nov 15 '18 at 10:29
@AndyG There is a 'Change User' option ont he Navigation panel, this re-opens the login form. When the user logs in it removes the tabledef objects using the second block of code and re-adds them using the new User/Pass however it's actually opening the connection using the original user/pass.
– bendataclear
Nov 15 '18 at 10:29
Also, is a general user able to use this facility? Should they be able to switch username without first exiting?
– Andy G
Nov 15 '18 at 10:29
Also, is a general user able to use this facility? Should they be able to switch username without first exiting?
– Andy G
Nov 15 '18 at 10:29
@AndyG Yes it's available for any user.
– bendataclear
Nov 15 '18 at 10:31
@AndyG Yes it's available for any user.
– bendataclear
Nov 15 '18 at 10:31
Access is a poor fit for this, but, in my opinion, your general User / Joe should not be able to switch user without exiting Access. Otherwise, as mentioned, it is during the process of changing user that the connection can be reset.
– Andy G
Nov 15 '18 at 10:32
Access is a poor fit for this, but, in my opinion, your general User / Joe should not be able to switch user without exiting Access. Otherwise, as mentioned, it is during the process of changing user that the connection can be reset.
– Andy G
Nov 15 '18 at 10:32
@AndyG I agree, Access is a poor fit but it's not possible to change it. Do you know how to reset the connection?
– bendataclear
Nov 15 '18 at 10:35
@AndyG I agree, Access is a poor fit but it's not possible to change it. Do you know how to reset the connection?
– bendataclear
Nov 15 '18 at 10:35
|
show 13 more comments
2 Answers
2
active
oldest
votes
A couple ideas to try. I only suggest these because they are easy to check.
Try renaming the old table first, then create the new table, then delete the old one. If you trick Access into thinking you are adding rather than replacing, it may cooperate.
Try adding another element to the connection string (other than UID, which Access treats in a special way) to make it unique per user. I believe you can add an arbitrary tag/value pair to an ODBC connection string and it gets ignored. For example
"ODBC;Driver=SQL Server;MyUniqueTag=" & stUserName & ";UID=" & stUserName
ODBC connection pools are unique per connection string, so this may fool Access into using a different connection pool because it doesn't know that
MyUniqueTag
isn't used by the ODBC driver.
add a comment |
EDIT
Took me a while to realise it. Your issue is that Access caches connections per server,database base. There is no way of clearing this cache (as far as i know of)
However there is a wayaround: The answer is to make the connection unique even if the server or db details haven't changed.
Using DSN Files
You cannot change database name or server name to make a connection unique, but you can change DSN file name which Access will see the connection as "unique" / new connection.
If you use the same DSN file, the connection becomes cached again, so you must use different DSN file for each login attempts.
Here is a general function which allows a user to logIn or logOut of your system. Each login will produce a new DNS file and make a new connection to your DB => allowing your logged in user to be the new user.
Below functions are just conceptual. Change according to your needs
and add error trappings.
Public Function FN_CREATE_DNS_FILE()
Const Server As String = "" ' Server
Const Driver As String = "" ' Driver
Const Port As String = "" ' Port
Const Database As String = "" ' Database
Dim DsnFileName As String
Dim Fso As Object
Dim DnsFile As Object
Set Fso = CreateObject("Scripting.FileSystemObject")
DsnFileName = VBA.Environ$("temp") & "" & VBA.Format(Now(), "yyyy-mm-dd_hh_mm_ss") & ".dsn"
Set DnsFile = Fso.CreateTextFile(DsnFileName)
DnsFile.WriteLine "[ODBC]"
DnsFile.WriteLine "DRIVER=" & Driver
DnsFile.WriteLine "PORT=" & Port
DnsFile.WriteLine "DATABASE=" & Database
DnsFile.WriteLine "SERVER=" & Server
'Close file and clean up
DnsFile.Close
Set Fso = Nothing
Set DnsFile = Nothing
FN_CREATE_DNS_FILE = DsnFileName
End Function
Public Function LogOut()
Dim Qdf As QueryDef
For Each Qdf In CurrentDb.QueryDefs
If (VBA.InStr(Qdf.Connect, "ODBC")) > 0 Then
Qdf.Connect = "ODBC;" 'Either delete if you don't require this object or set to blank connection string
End If
Next Qdf
End Function
Public Function LogIn(stUsername As String, stPassword As String)
Dim Tdf As TableDef
Dim Qdf As QueryDef
Dim stConnect As String
Dim ConForQuery As String
Dim I As Integer: I = 0
Dim DsnFileName As String
On Error GoTo AttachDSNLessTable_Err
'Produce new DNS file with new filename to make Acces Connection unique
DsnFileName = FN_CREATE_DNS_FILE()
stConnect = "ODBC;AUTO_RECONNECT=1;NO_PROMPT=1"
If Len(stUsername) = 0 Then
'//Use trusted authentication if stUsername is not supplied.
stConnect = stConnect & ";Trusted_Connection=Yes"
ConForQuery = stConnect
Else
'//WARNING: This will save the username and the password with the linked table information.
stConnect = stConnect & ";UID=" & stUsername & ";PWD=" & stPassword
ConForQuery = stConnect & ";UID=" & stUsername
End If
ConForQuery = ConForQuery & ";" & "FILEDSN=" & DsnFileName
stConnect = stConnect & ";" & "FILEDSN=" & DsnFileName
On Error GoTo ERROR_Invalid_login
'Update all linked tables
For Each Tdf In CurrentDb.TableDefs
If (VBA.InStr(Tdf.Connect, "ODBC")) > 0 Then
Tdf.Connect = stConnect & ";TABLE=" & Tdf.Name
If (I = 0) Then Tdf.RefreshLink 'Refreshing one table is enough as long as table definition hasnt changed
I = I + 1
End If
Next Tdf
'update all passthrough queries
For Each Qdf In CurrentDb.QueryDefs
If (VBA.InStr(Qdf.Connect, "ODBC")) > 0 Then
Qdf.Connect = stConnect
End If
Next Qdf
LogIn = ""
Exit Function
AttachDSNLessTable_Err:
LogIn = Err.Description
Exit Function
ERROR_Invalid_login:
LogIn = "Login failed"
LogOut 'Delete or set blank for all pass through queries
End Function
if a user logs in you would simply call
LogIn(Username, password)
which will update all linked tables as well as passthrough queries.
here is a screenshot.
QryCurrentUser executes MySQL command select user();
which shows the owner of the current connection.
As you can see, each login shows now correct logged in usernames.
If login fails, you have two options. Delete All linked in tables and passthrough queries. or set them to a blank connectionstring.
PS
I have added NO_PROMPT & AUTO_RECONNECT to the connectionstring which prevents showing database connection window when login fails and re-connects automatically (MySQL command, not sure if it works for MSSQL) remove them if not compatible.
Let me know if you were able to achieve this.
I've added in my login function to the question to clear things up.
– bendataclear
Nov 15 '18 at 12:50
I'm removing the tabledef and re-adding to avoid saving the username and password into the database. Otherwise when it's closed and re-opened, the file tables retain the last connected user, this is a security risk.
– bendataclear
Nov 15 '18 at 12:52
@bendataclear you don't need to provide username and password for all active connections. You can connect only one table, rest of the tables don't need username and password.
– krish KM
Nov 15 '18 at 12:57
Sorry I don't follow, will callingTdf.RefreshLink
use the new username and password? Because removing and re-adding the Tdf doesn't.
– bendataclear
Nov 15 '18 at 13:10
@bendataclear. yes. by default linked in tables don't save password. Close your db without deleting the tables. open access and don't login. now check the .connect property of a linked tables. you won't see password or userid.
– krish KM
Nov 15 '18 at 13:18
|
show 8 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53317092%2fforcing-access-to-forget-a-username-and-password-for-a-linked-table%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
A couple ideas to try. I only suggest these because they are easy to check.
Try renaming the old table first, then create the new table, then delete the old one. If you trick Access into thinking you are adding rather than replacing, it may cooperate.
Try adding another element to the connection string (other than UID, which Access treats in a special way) to make it unique per user. I believe you can add an arbitrary tag/value pair to an ODBC connection string and it gets ignored. For example
"ODBC;Driver=SQL Server;MyUniqueTag=" & stUserName & ";UID=" & stUserName
ODBC connection pools are unique per connection string, so this may fool Access into using a different connection pool because it doesn't know that
MyUniqueTag
isn't used by the ODBC driver.
add a comment |
A couple ideas to try. I only suggest these because they are easy to check.
Try renaming the old table first, then create the new table, then delete the old one. If you trick Access into thinking you are adding rather than replacing, it may cooperate.
Try adding another element to the connection string (other than UID, which Access treats in a special way) to make it unique per user. I believe you can add an arbitrary tag/value pair to an ODBC connection string and it gets ignored. For example
"ODBC;Driver=SQL Server;MyUniqueTag=" & stUserName & ";UID=" & stUserName
ODBC connection pools are unique per connection string, so this may fool Access into using a different connection pool because it doesn't know that
MyUniqueTag
isn't used by the ODBC driver.
add a comment |
A couple ideas to try. I only suggest these because they are easy to check.
Try renaming the old table first, then create the new table, then delete the old one. If you trick Access into thinking you are adding rather than replacing, it may cooperate.
Try adding another element to the connection string (other than UID, which Access treats in a special way) to make it unique per user. I believe you can add an arbitrary tag/value pair to an ODBC connection string and it gets ignored. For example
"ODBC;Driver=SQL Server;MyUniqueTag=" & stUserName & ";UID=" & stUserName
ODBC connection pools are unique per connection string, so this may fool Access into using a different connection pool because it doesn't know that
MyUniqueTag
isn't used by the ODBC driver.
A couple ideas to try. I only suggest these because they are easy to check.
Try renaming the old table first, then create the new table, then delete the old one. If you trick Access into thinking you are adding rather than replacing, it may cooperate.
Try adding another element to the connection string (other than UID, which Access treats in a special way) to make it unique per user. I believe you can add an arbitrary tag/value pair to an ODBC connection string and it gets ignored. For example
"ODBC;Driver=SQL Server;MyUniqueTag=" & stUserName & ";UID=" & stUserName
ODBC connection pools are unique per connection string, so this may fool Access into using a different connection pool because it doesn't know that
MyUniqueTag
isn't used by the ODBC driver.
answered Nov 15 '18 at 19:18
John WuJohn Wu
30.9k42753
30.9k42753
add a comment |
add a comment |
EDIT
Took me a while to realise it. Your issue is that Access caches connections per server,database base. There is no way of clearing this cache (as far as i know of)
However there is a wayaround: The answer is to make the connection unique even if the server or db details haven't changed.
Using DSN Files
You cannot change database name or server name to make a connection unique, but you can change DSN file name which Access will see the connection as "unique" / new connection.
If you use the same DSN file, the connection becomes cached again, so you must use different DSN file for each login attempts.
Here is a general function which allows a user to logIn or logOut of your system. Each login will produce a new DNS file and make a new connection to your DB => allowing your logged in user to be the new user.
Below functions are just conceptual. Change according to your needs
and add error trappings.
Public Function FN_CREATE_DNS_FILE()
Const Server As String = "" ' Server
Const Driver As String = "" ' Driver
Const Port As String = "" ' Port
Const Database As String = "" ' Database
Dim DsnFileName As String
Dim Fso As Object
Dim DnsFile As Object
Set Fso = CreateObject("Scripting.FileSystemObject")
DsnFileName = VBA.Environ$("temp") & "" & VBA.Format(Now(), "yyyy-mm-dd_hh_mm_ss") & ".dsn"
Set DnsFile = Fso.CreateTextFile(DsnFileName)
DnsFile.WriteLine "[ODBC]"
DnsFile.WriteLine "DRIVER=" & Driver
DnsFile.WriteLine "PORT=" & Port
DnsFile.WriteLine "DATABASE=" & Database
DnsFile.WriteLine "SERVER=" & Server
'Close file and clean up
DnsFile.Close
Set Fso = Nothing
Set DnsFile = Nothing
FN_CREATE_DNS_FILE = DsnFileName
End Function
Public Function LogOut()
Dim Qdf As QueryDef
For Each Qdf In CurrentDb.QueryDefs
If (VBA.InStr(Qdf.Connect, "ODBC")) > 0 Then
Qdf.Connect = "ODBC;" 'Either delete if you don't require this object or set to blank connection string
End If
Next Qdf
End Function
Public Function LogIn(stUsername As String, stPassword As String)
Dim Tdf As TableDef
Dim Qdf As QueryDef
Dim stConnect As String
Dim ConForQuery As String
Dim I As Integer: I = 0
Dim DsnFileName As String
On Error GoTo AttachDSNLessTable_Err
'Produce new DNS file with new filename to make Acces Connection unique
DsnFileName = FN_CREATE_DNS_FILE()
stConnect = "ODBC;AUTO_RECONNECT=1;NO_PROMPT=1"
If Len(stUsername) = 0 Then
'//Use trusted authentication if stUsername is not supplied.
stConnect = stConnect & ";Trusted_Connection=Yes"
ConForQuery = stConnect
Else
'//WARNING: This will save the username and the password with the linked table information.
stConnect = stConnect & ";UID=" & stUsername & ";PWD=" & stPassword
ConForQuery = stConnect & ";UID=" & stUsername
End If
ConForQuery = ConForQuery & ";" & "FILEDSN=" & DsnFileName
stConnect = stConnect & ";" & "FILEDSN=" & DsnFileName
On Error GoTo ERROR_Invalid_login
'Update all linked tables
For Each Tdf In CurrentDb.TableDefs
If (VBA.InStr(Tdf.Connect, "ODBC")) > 0 Then
Tdf.Connect = stConnect & ";TABLE=" & Tdf.Name
If (I = 0) Then Tdf.RefreshLink 'Refreshing one table is enough as long as table definition hasnt changed
I = I + 1
End If
Next Tdf
'update all passthrough queries
For Each Qdf In CurrentDb.QueryDefs
If (VBA.InStr(Qdf.Connect, "ODBC")) > 0 Then
Qdf.Connect = stConnect
End If
Next Qdf
LogIn = ""
Exit Function
AttachDSNLessTable_Err:
LogIn = Err.Description
Exit Function
ERROR_Invalid_login:
LogIn = "Login failed"
LogOut 'Delete or set blank for all pass through queries
End Function
if a user logs in you would simply call
LogIn(Username, password)
which will update all linked tables as well as passthrough queries.
here is a screenshot.
QryCurrentUser executes MySQL command select user();
which shows the owner of the current connection.
As you can see, each login shows now correct logged in usernames.
If login fails, you have two options. Delete All linked in tables and passthrough queries. or set them to a blank connectionstring.
PS
I have added NO_PROMPT & AUTO_RECONNECT to the connectionstring which prevents showing database connection window when login fails and re-connects automatically (MySQL command, not sure if it works for MSSQL) remove them if not compatible.
Let me know if you were able to achieve this.
I've added in my login function to the question to clear things up.
– bendataclear
Nov 15 '18 at 12:50
I'm removing the tabledef and re-adding to avoid saving the username and password into the database. Otherwise when it's closed and re-opened, the file tables retain the last connected user, this is a security risk.
– bendataclear
Nov 15 '18 at 12:52
@bendataclear you don't need to provide username and password for all active connections. You can connect only one table, rest of the tables don't need username and password.
– krish KM
Nov 15 '18 at 12:57
Sorry I don't follow, will callingTdf.RefreshLink
use the new username and password? Because removing and re-adding the Tdf doesn't.
– bendataclear
Nov 15 '18 at 13:10
@bendataclear. yes. by default linked in tables don't save password. Close your db without deleting the tables. open access and don't login. now check the .connect property of a linked tables. you won't see password or userid.
– krish KM
Nov 15 '18 at 13:18
|
show 8 more comments
EDIT
Took me a while to realise it. Your issue is that Access caches connections per server,database base. There is no way of clearing this cache (as far as i know of)
However there is a wayaround: The answer is to make the connection unique even if the server or db details haven't changed.
Using DSN Files
You cannot change database name or server name to make a connection unique, but you can change DSN file name which Access will see the connection as "unique" / new connection.
If you use the same DSN file, the connection becomes cached again, so you must use different DSN file for each login attempts.
Here is a general function which allows a user to logIn or logOut of your system. Each login will produce a new DNS file and make a new connection to your DB => allowing your logged in user to be the new user.
Below functions are just conceptual. Change according to your needs
and add error trappings.
Public Function FN_CREATE_DNS_FILE()
Const Server As String = "" ' Server
Const Driver As String = "" ' Driver
Const Port As String = "" ' Port
Const Database As String = "" ' Database
Dim DsnFileName As String
Dim Fso As Object
Dim DnsFile As Object
Set Fso = CreateObject("Scripting.FileSystemObject")
DsnFileName = VBA.Environ$("temp") & "" & VBA.Format(Now(), "yyyy-mm-dd_hh_mm_ss") & ".dsn"
Set DnsFile = Fso.CreateTextFile(DsnFileName)
DnsFile.WriteLine "[ODBC]"
DnsFile.WriteLine "DRIVER=" & Driver
DnsFile.WriteLine "PORT=" & Port
DnsFile.WriteLine "DATABASE=" & Database
DnsFile.WriteLine "SERVER=" & Server
'Close file and clean up
DnsFile.Close
Set Fso = Nothing
Set DnsFile = Nothing
FN_CREATE_DNS_FILE = DsnFileName
End Function
Public Function LogOut()
Dim Qdf As QueryDef
For Each Qdf In CurrentDb.QueryDefs
If (VBA.InStr(Qdf.Connect, "ODBC")) > 0 Then
Qdf.Connect = "ODBC;" 'Either delete if you don't require this object or set to blank connection string
End If
Next Qdf
End Function
Public Function LogIn(stUsername As String, stPassword As String)
Dim Tdf As TableDef
Dim Qdf As QueryDef
Dim stConnect As String
Dim ConForQuery As String
Dim I As Integer: I = 0
Dim DsnFileName As String
On Error GoTo AttachDSNLessTable_Err
'Produce new DNS file with new filename to make Acces Connection unique
DsnFileName = FN_CREATE_DNS_FILE()
stConnect = "ODBC;AUTO_RECONNECT=1;NO_PROMPT=1"
If Len(stUsername) = 0 Then
'//Use trusted authentication if stUsername is not supplied.
stConnect = stConnect & ";Trusted_Connection=Yes"
ConForQuery = stConnect
Else
'//WARNING: This will save the username and the password with the linked table information.
stConnect = stConnect & ";UID=" & stUsername & ";PWD=" & stPassword
ConForQuery = stConnect & ";UID=" & stUsername
End If
ConForQuery = ConForQuery & ";" & "FILEDSN=" & DsnFileName
stConnect = stConnect & ";" & "FILEDSN=" & DsnFileName
On Error GoTo ERROR_Invalid_login
'Update all linked tables
For Each Tdf In CurrentDb.TableDefs
If (VBA.InStr(Tdf.Connect, "ODBC")) > 0 Then
Tdf.Connect = stConnect & ";TABLE=" & Tdf.Name
If (I = 0) Then Tdf.RefreshLink 'Refreshing one table is enough as long as table definition hasnt changed
I = I + 1
End If
Next Tdf
'update all passthrough queries
For Each Qdf In CurrentDb.QueryDefs
If (VBA.InStr(Qdf.Connect, "ODBC")) > 0 Then
Qdf.Connect = stConnect
End If
Next Qdf
LogIn = ""
Exit Function
AttachDSNLessTable_Err:
LogIn = Err.Description
Exit Function
ERROR_Invalid_login:
LogIn = "Login failed"
LogOut 'Delete or set blank for all pass through queries
End Function
if a user logs in you would simply call
LogIn(Username, password)
which will update all linked tables as well as passthrough queries.
here is a screenshot.
QryCurrentUser executes MySQL command select user();
which shows the owner of the current connection.
As you can see, each login shows now correct logged in usernames.
If login fails, you have two options. Delete All linked in tables and passthrough queries. or set them to a blank connectionstring.
PS
I have added NO_PROMPT & AUTO_RECONNECT to the connectionstring which prevents showing database connection window when login fails and re-connects automatically (MySQL command, not sure if it works for MSSQL) remove them if not compatible.
Let me know if you were able to achieve this.
I've added in my login function to the question to clear things up.
– bendataclear
Nov 15 '18 at 12:50
I'm removing the tabledef and re-adding to avoid saving the username and password into the database. Otherwise when it's closed and re-opened, the file tables retain the last connected user, this is a security risk.
– bendataclear
Nov 15 '18 at 12:52
@bendataclear you don't need to provide username and password for all active connections. You can connect only one table, rest of the tables don't need username and password.
– krish KM
Nov 15 '18 at 12:57
Sorry I don't follow, will callingTdf.RefreshLink
use the new username and password? Because removing and re-adding the Tdf doesn't.
– bendataclear
Nov 15 '18 at 13:10
@bendataclear. yes. by default linked in tables don't save password. Close your db without deleting the tables. open access and don't login. now check the .connect property of a linked tables. you won't see password or userid.
– krish KM
Nov 15 '18 at 13:18
|
show 8 more comments
EDIT
Took me a while to realise it. Your issue is that Access caches connections per server,database base. There is no way of clearing this cache (as far as i know of)
However there is a wayaround: The answer is to make the connection unique even if the server or db details haven't changed.
Using DSN Files
You cannot change database name or server name to make a connection unique, but you can change DSN file name which Access will see the connection as "unique" / new connection.
If you use the same DSN file, the connection becomes cached again, so you must use different DSN file for each login attempts.
Here is a general function which allows a user to logIn or logOut of your system. Each login will produce a new DNS file and make a new connection to your DB => allowing your logged in user to be the new user.
Below functions are just conceptual. Change according to your needs
and add error trappings.
Public Function FN_CREATE_DNS_FILE()
Const Server As String = "" ' Server
Const Driver As String = "" ' Driver
Const Port As String = "" ' Port
Const Database As String = "" ' Database
Dim DsnFileName As String
Dim Fso As Object
Dim DnsFile As Object
Set Fso = CreateObject("Scripting.FileSystemObject")
DsnFileName = VBA.Environ$("temp") & "" & VBA.Format(Now(), "yyyy-mm-dd_hh_mm_ss") & ".dsn"
Set DnsFile = Fso.CreateTextFile(DsnFileName)
DnsFile.WriteLine "[ODBC]"
DnsFile.WriteLine "DRIVER=" & Driver
DnsFile.WriteLine "PORT=" & Port
DnsFile.WriteLine "DATABASE=" & Database
DnsFile.WriteLine "SERVER=" & Server
'Close file and clean up
DnsFile.Close
Set Fso = Nothing
Set DnsFile = Nothing
FN_CREATE_DNS_FILE = DsnFileName
End Function
Public Function LogOut()
Dim Qdf As QueryDef
For Each Qdf In CurrentDb.QueryDefs
If (VBA.InStr(Qdf.Connect, "ODBC")) > 0 Then
Qdf.Connect = "ODBC;" 'Either delete if you don't require this object or set to blank connection string
End If
Next Qdf
End Function
Public Function LogIn(stUsername As String, stPassword As String)
Dim Tdf As TableDef
Dim Qdf As QueryDef
Dim stConnect As String
Dim ConForQuery As String
Dim I As Integer: I = 0
Dim DsnFileName As String
On Error GoTo AttachDSNLessTable_Err
'Produce new DNS file with new filename to make Acces Connection unique
DsnFileName = FN_CREATE_DNS_FILE()
stConnect = "ODBC;AUTO_RECONNECT=1;NO_PROMPT=1"
If Len(stUsername) = 0 Then
'//Use trusted authentication if stUsername is not supplied.
stConnect = stConnect & ";Trusted_Connection=Yes"
ConForQuery = stConnect
Else
'//WARNING: This will save the username and the password with the linked table information.
stConnect = stConnect & ";UID=" & stUsername & ";PWD=" & stPassword
ConForQuery = stConnect & ";UID=" & stUsername
End If
ConForQuery = ConForQuery & ";" & "FILEDSN=" & DsnFileName
stConnect = stConnect & ";" & "FILEDSN=" & DsnFileName
On Error GoTo ERROR_Invalid_login
'Update all linked tables
For Each Tdf In CurrentDb.TableDefs
If (VBA.InStr(Tdf.Connect, "ODBC")) > 0 Then
Tdf.Connect = stConnect & ";TABLE=" & Tdf.Name
If (I = 0) Then Tdf.RefreshLink 'Refreshing one table is enough as long as table definition hasnt changed
I = I + 1
End If
Next Tdf
'update all passthrough queries
For Each Qdf In CurrentDb.QueryDefs
If (VBA.InStr(Qdf.Connect, "ODBC")) > 0 Then
Qdf.Connect = stConnect
End If
Next Qdf
LogIn = ""
Exit Function
AttachDSNLessTable_Err:
LogIn = Err.Description
Exit Function
ERROR_Invalid_login:
LogIn = "Login failed"
LogOut 'Delete or set blank for all pass through queries
End Function
if a user logs in you would simply call
LogIn(Username, password)
which will update all linked tables as well as passthrough queries.
here is a screenshot.
QryCurrentUser executes MySQL command select user();
which shows the owner of the current connection.
As you can see, each login shows now correct logged in usernames.
If login fails, you have two options. Delete All linked in tables and passthrough queries. or set them to a blank connectionstring.
PS
I have added NO_PROMPT & AUTO_RECONNECT to the connectionstring which prevents showing database connection window when login fails and re-connects automatically (MySQL command, not sure if it works for MSSQL) remove them if not compatible.
Let me know if you were able to achieve this.
EDIT
Took me a while to realise it. Your issue is that Access caches connections per server,database base. There is no way of clearing this cache (as far as i know of)
However there is a wayaround: The answer is to make the connection unique even if the server or db details haven't changed.
Using DSN Files
You cannot change database name or server name to make a connection unique, but you can change DSN file name which Access will see the connection as "unique" / new connection.
If you use the same DSN file, the connection becomes cached again, so you must use different DSN file for each login attempts.
Here is a general function which allows a user to logIn or logOut of your system. Each login will produce a new DNS file and make a new connection to your DB => allowing your logged in user to be the new user.
Below functions are just conceptual. Change according to your needs
and add error trappings.
Public Function FN_CREATE_DNS_FILE()
Const Server As String = "" ' Server
Const Driver As String = "" ' Driver
Const Port As String = "" ' Port
Const Database As String = "" ' Database
Dim DsnFileName As String
Dim Fso As Object
Dim DnsFile As Object
Set Fso = CreateObject("Scripting.FileSystemObject")
DsnFileName = VBA.Environ$("temp") & "" & VBA.Format(Now(), "yyyy-mm-dd_hh_mm_ss") & ".dsn"
Set DnsFile = Fso.CreateTextFile(DsnFileName)
DnsFile.WriteLine "[ODBC]"
DnsFile.WriteLine "DRIVER=" & Driver
DnsFile.WriteLine "PORT=" & Port
DnsFile.WriteLine "DATABASE=" & Database
DnsFile.WriteLine "SERVER=" & Server
'Close file and clean up
DnsFile.Close
Set Fso = Nothing
Set DnsFile = Nothing
FN_CREATE_DNS_FILE = DsnFileName
End Function
Public Function LogOut()
Dim Qdf As QueryDef
For Each Qdf In CurrentDb.QueryDefs
If (VBA.InStr(Qdf.Connect, "ODBC")) > 0 Then
Qdf.Connect = "ODBC;" 'Either delete if you don't require this object or set to blank connection string
End If
Next Qdf
End Function
Public Function LogIn(stUsername As String, stPassword As String)
Dim Tdf As TableDef
Dim Qdf As QueryDef
Dim stConnect As String
Dim ConForQuery As String
Dim I As Integer: I = 0
Dim DsnFileName As String
On Error GoTo AttachDSNLessTable_Err
'Produce new DNS file with new filename to make Acces Connection unique
DsnFileName = FN_CREATE_DNS_FILE()
stConnect = "ODBC;AUTO_RECONNECT=1;NO_PROMPT=1"
If Len(stUsername) = 0 Then
'//Use trusted authentication if stUsername is not supplied.
stConnect = stConnect & ";Trusted_Connection=Yes"
ConForQuery = stConnect
Else
'//WARNING: This will save the username and the password with the linked table information.
stConnect = stConnect & ";UID=" & stUsername & ";PWD=" & stPassword
ConForQuery = stConnect & ";UID=" & stUsername
End If
ConForQuery = ConForQuery & ";" & "FILEDSN=" & DsnFileName
stConnect = stConnect & ";" & "FILEDSN=" & DsnFileName
On Error GoTo ERROR_Invalid_login
'Update all linked tables
For Each Tdf In CurrentDb.TableDefs
If (VBA.InStr(Tdf.Connect, "ODBC")) > 0 Then
Tdf.Connect = stConnect & ";TABLE=" & Tdf.Name
If (I = 0) Then Tdf.RefreshLink 'Refreshing one table is enough as long as table definition hasnt changed
I = I + 1
End If
Next Tdf
'update all passthrough queries
For Each Qdf In CurrentDb.QueryDefs
If (VBA.InStr(Qdf.Connect, "ODBC")) > 0 Then
Qdf.Connect = stConnect
End If
Next Qdf
LogIn = ""
Exit Function
AttachDSNLessTable_Err:
LogIn = Err.Description
Exit Function
ERROR_Invalid_login:
LogIn = "Login failed"
LogOut 'Delete or set blank for all pass through queries
End Function
if a user logs in you would simply call
LogIn(Username, password)
which will update all linked tables as well as passthrough queries.
here is a screenshot.
QryCurrentUser executes MySQL command select user();
which shows the owner of the current connection.
As you can see, each login shows now correct logged in usernames.
If login fails, you have two options. Delete All linked in tables and passthrough queries. or set them to a blank connectionstring.
PS
I have added NO_PROMPT & AUTO_RECONNECT to the connectionstring which prevents showing database connection window when login fails and re-connects automatically (MySQL command, not sure if it works for MSSQL) remove them if not compatible.
Let me know if you were able to achieve this.
edited Nov 15 '18 at 19:28
Parfait
52.7k94471
52.7k94471
answered Nov 15 '18 at 12:34
krish KMkrish KM
4,4411728
4,4411728
I've added in my login function to the question to clear things up.
– bendataclear
Nov 15 '18 at 12:50
I'm removing the tabledef and re-adding to avoid saving the username and password into the database. Otherwise when it's closed and re-opened, the file tables retain the last connected user, this is a security risk.
– bendataclear
Nov 15 '18 at 12:52
@bendataclear you don't need to provide username and password for all active connections. You can connect only one table, rest of the tables don't need username and password.
– krish KM
Nov 15 '18 at 12:57
Sorry I don't follow, will callingTdf.RefreshLink
use the new username and password? Because removing and re-adding the Tdf doesn't.
– bendataclear
Nov 15 '18 at 13:10
@bendataclear. yes. by default linked in tables don't save password. Close your db without deleting the tables. open access and don't login. now check the .connect property of a linked tables. you won't see password or userid.
– krish KM
Nov 15 '18 at 13:18
|
show 8 more comments
I've added in my login function to the question to clear things up.
– bendataclear
Nov 15 '18 at 12:50
I'm removing the tabledef and re-adding to avoid saving the username and password into the database. Otherwise when it's closed and re-opened, the file tables retain the last connected user, this is a security risk.
– bendataclear
Nov 15 '18 at 12:52
@bendataclear you don't need to provide username and password for all active connections. You can connect only one table, rest of the tables don't need username and password.
– krish KM
Nov 15 '18 at 12:57
Sorry I don't follow, will callingTdf.RefreshLink
use the new username and password? Because removing and re-adding the Tdf doesn't.
– bendataclear
Nov 15 '18 at 13:10
@bendataclear. yes. by default linked in tables don't save password. Close your db without deleting the tables. open access and don't login. now check the .connect property of a linked tables. you won't see password or userid.
– krish KM
Nov 15 '18 at 13:18
I've added in my login function to the question to clear things up.
– bendataclear
Nov 15 '18 at 12:50
I've added in my login function to the question to clear things up.
– bendataclear
Nov 15 '18 at 12:50
I'm removing the tabledef and re-adding to avoid saving the username and password into the database. Otherwise when it's closed and re-opened, the file tables retain the last connected user, this is a security risk.
– bendataclear
Nov 15 '18 at 12:52
I'm removing the tabledef and re-adding to avoid saving the username and password into the database. Otherwise when it's closed and re-opened, the file tables retain the last connected user, this is a security risk.
– bendataclear
Nov 15 '18 at 12:52
@bendataclear you don't need to provide username and password for all active connections. You can connect only one table, rest of the tables don't need username and password.
– krish KM
Nov 15 '18 at 12:57
@bendataclear you don't need to provide username and password for all active connections. You can connect only one table, rest of the tables don't need username and password.
– krish KM
Nov 15 '18 at 12:57
Sorry I don't follow, will calling
Tdf.RefreshLink
use the new username and password? Because removing and re-adding the Tdf doesn't.– bendataclear
Nov 15 '18 at 13:10
Sorry I don't follow, will calling
Tdf.RefreshLink
use the new username and password? Because removing and re-adding the Tdf doesn't.– bendataclear
Nov 15 '18 at 13:10
@bendataclear. yes. by default linked in tables don't save password. Close your db without deleting the tables. open access and don't login. now check the .connect property of a linked tables. you won't see password or userid.
– krish KM
Nov 15 '18 at 13:18
@bendataclear. yes. by default linked in tables don't save password. Close your db without deleting the tables. open access and don't login. now check the .connect property of a linked tables. you won't see password or userid.
– krish KM
Nov 15 '18 at 13:18
|
show 8 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53317092%2fforcing-access-to-forget-a-username-and-password-for-a-linked-table%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
@AndyG There is a 'Change User' option ont he Navigation panel, this re-opens the login form. When the user logs in it removes the tabledef objects using the second block of code and re-adds them using the new User/Pass however it's actually opening the connection using the original user/pass.
– bendataclear
Nov 15 '18 at 10:29
Also, is a general user able to use this facility? Should they be able to switch username without first exiting?
– Andy G
Nov 15 '18 at 10:29
@AndyG Yes it's available for any user.
– bendataclear
Nov 15 '18 at 10:31
Access is a poor fit for this, but, in my opinion, your general User / Joe should not be able to switch user without exiting Access. Otherwise, as mentioned, it is during the process of changing user that the connection can be reset.
– Andy G
Nov 15 '18 at 10:32
@AndyG I agree, Access is a poor fit but it's not possible to change it. Do you know how to reset the connection?
– bendataclear
Nov 15 '18 at 10:35