Hi all
Wondering if I could get some help here for this very bizarre issue. I have created a login form for my FE Access App with a SQL Server BE. The user passes in their SQL Login and password and its authenticated against the server. I am using their ID for table audit purposes. When the user logs, in, their connection string is build dynamically using the connection string below
after which i reconnect to all linked tables in a loop and refresh the connection strings as below.
I have verified using SQL Profiler that all the linked tables and passthrough queries have their connections updated.
Problem im now encountering is when one of the main forms in the app is opened, when the save command runs either through a docmd.runcommand accmdsaverecord or by tabbing away from particular control, SQL sees the transaction (update) running through a previously logged in user account is using that ID as part of the audit. Even though i have verified that User A is logged into the app and all tables have had their connection strings updated, the transaction to update the form/record is being passed to SQL as User B. I have checked all the connections I'm using in the app through ADODB and DAO ensuring each one of them is closed and set to nothing after use so I'm really not sure how or where User B is getting cached in the system. I have found that after a couple of attempts logging in and out of the app, the correct user is passed to SQL but the cycle starts all over again when i log in as another user.
Wondering if I could get some help here for this very bizarre issue. I have created a login form for my FE Access App with a SQL Server BE. The user passes in their SQL Login and password and its authenticated against the server. I am using their ID for table audit purposes. When the user logs, in, their connection string is build dynamically using the connection string below
Code:
cs = "DRIVER=SQL Server Native Client 11.0;SERVER=SERVER\INSTANCE;UID=" & struser & ";PWD=" & strpw & ";APP=Microsoft Office;DATABASE=DBNAME;"
Code:
Set db = CurrentDb
For Each tdf In db.TableDefs
' Only make a change if the table is a linked table
If Len(tdf.Connect) Then
tdf.Connect = "DRIVER=SQL Server Native Client 11.0;SERVER=SERVER\INSTANCE;UID=" & struser & ";PWD=" & strpw & ";APP=Microsoft Office;DATABASE=DBNAME;"
tdf.RefreshLink
End If
Next
I have verified using SQL Profiler that all the linked tables and passthrough queries have their connections updated.
Problem im now encountering is when one of the main forms in the app is opened, when the save command runs either through a docmd.runcommand accmdsaverecord or by tabbing away from particular control, SQL sees the transaction (update) running through a previously logged in user account is using that ID as part of the audit. Even though i have verified that User A is logged into the app and all tables have had their connection strings updated, the transaction to update the form/record is being passed to SQL as User B. I have checked all the connections I'm using in the app through ADODB and DAO ensuring each one of them is closed and set to nothing after use so I'm really not sure how or where User B is getting cached in the system. I have found that after a couple of attempts logging in and out of the app, the correct user is passed to SQL but the cycle starts all over again when i log in as another user.