Thanks in advance.
Michael
We work with udl-files and a disconnected adp which connects
to the sql-server on startup.
Here is the code for the "auto connect" ;-)
Public Function ReConnectToSQLServer
Private const cUDLFile As String = "MyConnection.udl"
Set cnn = CreateObject("ADODB.Connection")
SysCmd acSysCmdSetStatus, "Connection to SQL-Server..."
' Get the path of the application
' UDL-File must exist in the same directory
strFilePath = CurrentProject.Path
' Determine the file path
If Right(strFilePath, 1) = "\" Then
strFile = strFilePath & cUDLFile
Else
strFile = strFilePath & "\" & cUDLFile
End If
If Dir(strFile, vbNormal) <> vbNullString Then
' If the udl-file exists ...
If strFile <> vbNullString Then
With cnn
On Error Resume Next
strFile = "File Name=" & strFile
.Open strFile
If Err.Number > 0 Then
MsgBox cstrMsgErrorInConnection, vbInformation,
Application.Name
DoCmd.Quit
End If
If .State = 0 Then
MsgBox "Failure - Noc connection established",
vbInformation, Application.Name
DoCmd.Quit
Else
CurrentProject.OpenConnection .ConnectionString
End If
End With
Else
MsgBox "Failure - No connection established",
vbInformation, Application.Name
DoCmd.Quit
End If
Else
MsgBox "Failure - No connection established", vbInformation,
Application.Name
DoCmd.Quit
End If
SysCmd acSysCmdClearStatus
End Function
HTH ;-)
--
Gruß, Uwe Ricken
MCP FOR MS ACCESS DEVELOPMENT
GNS GmbH, Frankfurt am Main
http://www.gns-online.de
http://www.memberadmin.com
____________________________________________________
APP: http://www.AccessProfiPool.de
FAQ: http://www.donkarl.com/AccessFAQ.htm
Thanks.
Michael
"Uwe Ricken" <ric...@gns-online.de> wrote in message
news:#7WO6L#4CHA...@TK2MSFTNGP11.phx.gbl...
> Thank you for answer, maybe I should be more clear, but my problem
is how to
> avoid adp from connecting
As I described ;-)
Deliver an adp with no connection.
e.g. CurrentProject.Connection = vbNullString
In this case the adp is disconnected from any server
This adp can be delivered to the customers
On startup of the adp open a form, where all possible
servers can be selected from within a list box.
"Uwe Ricken" <ric...@gns-online.de> wrote in message
news:OtWlOvA5...@TK2MSFTNGP12.phx.gbl...