Hello,
I am in need of a function that will automatically link to my SQL DB upon logging into the App. I have set up an AUTOEXEC command that calls a module. In the module I have the following code:
Dim cnlink As New ADODB.Connection
Dim cnlink As New ADODB.Connection
Dim rst As ADODB.Recordset
Dim strConnectionString As String
Dim strSQL As String
Set cnlink = New ADODB.Connection
strConnectionString = "Provider=SQLOLEDB;" & _
"Data Source=SERVERNAME;" & _
"Initial Catalog=DBNAME;" & _
"User ID=sa" & _
";Password=password"
cnlink.Open (strConnectionString)
However, when I try to add it to Macro for Action RUN CODE I put in the name of the module which is RelinkDB(). I am getting an error like the following when trying to run this: expression you entered has a function name that Access can't find.
Any ideas on why I am getting this error? If I could get this to work then all tables to this Database would link on open rather than prompting for DB user name and password each time connect (for 1st time) to that DB. Isn't that correct? Any help would be greatly appreciated.
I am in need of a function that will automatically link to my SQL DB upon logging into the App. I have set up an AUTOEXEC command that calls a module. In the module I have the following code:
Dim cnlink As New ADODB.Connection
Dim cnlink As New ADODB.Connection
Dim rst As ADODB.Recordset
Dim strConnectionString As String
Dim strSQL As String
Set cnlink = New ADODB.Connection
strConnectionString = "Provider=SQLOLEDB;" & _
"Data Source=SERVERNAME;" & _
"Initial Catalog=DBNAME;" & _
"User ID=sa" & _
";Password=password"
cnlink.Open (strConnectionString)
However, when I try to add it to Macro for Action RUN CODE I put in the name of the module which is RelinkDB(). I am getting an error like the following when trying to run this: expression you entered has a function name that Access can't find.
Any ideas on why I am getting this error? If I could get this to work then all tables to this Database would link on open rather than prompting for DB user name and password each time connect (for 1st time) to that DB. Isn't that correct? Any help would be greatly appreciated.