I have upsized an Access application to a SQL server back end and I cannot login using VBA code.
I have produced a really simple test set up with just one attached table and I am using this code directly from my autoexec
Dim cn As New ADODB.Connection
Set cn = New ADODB.Connection
Dim strQuery As String
strQuery = "Provider='sqloledb';Data Source='reddwarf';Initial Catalog='SISExpress';User Id='Test';Password='test'"
cn.Open strQuery
If cn.State = adStateOpen Then MsgBox "Connected"
Dim rst As Recordset
Set rst = CurrentDb.OpenRecordset("SELECT * FROM tblStudents")
Now, as far as I can see it connects OK and returns adStateOpen
BUT as soon as I try to run a query of any sort Access tries to connect again and insists on using Trusted Connection (which isn't going to work because we have a Novell network)
Anybody got any ideas? As far as I can see and I've done a fair bit of Googling and read many posts on here - this is a sensible thing to try - but why doesn't it work?
I might add that if you uncheck the trusted connection from the error dialog you can then log in manually with no problems. A colleague has written a simple test in .NET which connects to the same database without problem.
I have produced a really simple test set up with just one attached table and I am using this code directly from my autoexec
Dim cn As New ADODB.Connection
Set cn = New ADODB.Connection
Dim strQuery As String
strQuery = "Provider='sqloledb';Data Source='reddwarf';Initial Catalog='SISExpress';User Id='Test';Password='test'"
cn.Open strQuery
If cn.State = adStateOpen Then MsgBox "Connected"
Dim rst As Recordset
Set rst = CurrentDb.OpenRecordset("SELECT * FROM tblStudents")
Now, as far as I can see it connects OK and returns adStateOpen
BUT as soon as I try to run a query of any sort Access tries to connect again and insists on using Trusted Connection (which isn't going to work because we have a Novell network)
Anybody got any ideas? As far as I can see and I've done a fair bit of Googling and read many posts on here - this is a sensible thing to try - but why doesn't it work?
I might add that if you uncheck the trusted connection from the error dialog you can then log in manually with no problems. A colleague has written a simple test in .NET which connects to the same database without problem.