I have the following code that use to work fine when my front end was in a .ACCDB file. After I migrated the backend to SQL server I changed the fron end to a .adp file and now my code won't work. I get the following error message "Run-Time error 91". Can someone please help.
Sub GetDBUsers()
Dim db As Database
Dim rst As Recordset
Dim StrSQL As String
StrSQL = "SELECT UserName FROM Employee ORDER BY UserName"
Set db = CurrentDb
Set rst = db.OpenRecordset(StrSQL)
rst.MoveFirst
While Not rst.EOF
Debug.Print rst!UserName
rst.MoveNext
Wend
Set db = Nothing
Set rst = Nothing
End Sub
Sub GetDBUsers()
Dim db As Database
Dim rst As Recordset
Dim StrSQL As String
StrSQL = "SELECT UserName FROM Employee ORDER BY UserName"
Set db = CurrentDb
Set rst = db.OpenRecordset(StrSQL)
rst.MoveFirst
While Not rst.EOF
Debug.Print rst!UserName
rst.MoveNext
Wend
Set db = Nothing
Set rst = Nothing
End Sub