Or, you can use both... I open the application with NT Authentication and then switch to an Application ID. The users have no permissions to database objects directly... thereby, all database objects can only be updated via the Application ID. htwh,
Code excerpt below...
from Autoexec Module...
'Check NT Authority
DBConnResult = False
DBConnResult = ChangeADPConnection("Server", "dBName")
If DBConnResult = False Then
'User is not autorized to backend SQL Server
MsgBox(lcMsg, lcStyle1, lcTitle)
Application.CurrentProject.CloseConnection
Application.Quit acQuitSaveAll
End If
'Set Application Id
DBConnResult = False
DBConnResult = ChangeADPConnection("Server", "DbName", lcLoginId, lcPassword)
If DBConnResult = False Then
msgbox('''Error;;; ...
Function ChangeADPConnection(strServerName As String, strDBName As _
String, Optional strUN As String, Optional strPW As String) As Boolean
Dim strConnect As String
On Error GoTo EH:
Application.CurrentProject.CloseConnection
'The Provider, Data Source, and Initial Catalog arguments are required.
strConnect = "Provider=SQLOLEDB.1" & _
";Data Source=" & strServerName & _
";Initial Catalog=" & strDBName
If strUN <> "" Then
strConnect = strConnect & ";user id=" & strUN
If strPW <> "" Then
strConnect = strConnect & ";password=" & strPW
End If
Else 'Try to use integrated security if no username is supplied.
strConnect = strConnect & ";integrated security=SSPI"
End If
Application.CurrentProject.OpenConnection strConnect
ChangeADPConnection = True
Exit Function
EH:
'MsgBox Err.Number & ": " & Err.Description, vbCritical, "Connection Error"
ChangeADPConnection = False
End Function
Steve Medvid
"IT Consultant & Web Master"
Chester County, PA Residents
Please Show Your Support...