Article ID: 202615
Article Last Modified on 1/26/2005
Option Compare Database
Option Explicit
Sub subDisconnect()
Application.CurrentProject.CloseConnection
Application.CurrentProject.OpenConnection
End Sub
Function fncConnect()
Dim strServer As String 'The name of the MSDE or SQL Server.
Dim strUser As String 'The user name for logging in.
Dim strPwd As String 'The user password for logging in.
Dim strDB As String 'The name of the source database.
Dim strConnection As String 'Connection settings.
Dim strPrompt As String 'Message to display if error occurs.
Dim intBtns As Integer 'Buttons/icon to display on error message.
Dim strTitle As String 'Title bar of error message.
Dim intRetVal As Integer 'Button clicked on error message.
On Error GoTo ConnectionErr
strServer = "<ServerName>" 'Enter the actual name of your server.
strUser = "sa"
strPwd = ""
strDB = "<DatabaseName>" 'Enter the actual database name.
strConnection = "Provider=SQLOLEDB.1" & _
";Persist Security Info=True" & _
";Data Source=" & strServer & _
";User ID=" & strUser & _
";Password=" & strPwd & _
";Initial Catalog=" & strDB
Application.CurrentProject.OpenConnection strConnection
ConnectExit:
Exit Function
ConnectionErr:
strPrompt = Err.Description
intBtns = vbApplicationModal + vbExclamation + vbOKOnly
strTitle = "ERROR #" & Err.Number
intRetVal = MsgBox(strPrompt, intBtns, strTitle)
Resume ConnectExit
End Function
In the code, be sure to replace <ServerName> with the actual name of your Microsoft Data Engine (MSDE) or SQL Server, and replace <DatabaseName> with the actual name of your MSDE or SQL Server database.Additional query words: adp checkbox checked prb pra logon log-in unchecked
Keywords: kbbug kbclientserver kbpending KB202615