Hi,
I am trying to get this code to work, but it keeps stoping on the cn (Set cn = OpenConnection("", dbDriverComplete, False, scn)) line for the connection to the SQL Server. The error says that the opperation is not supported by this type of object. I got this from a book, As usal I think they are leaving some code out. And I need a way to do this through ODBC, because that is what the company wants.
Here is my code:
Private Sub Form_Load()
Dim db As Database
Dim cn As Connection
Dim rs As Recordset
Dim rs2 As Recordset
Dim scn As String
Dim strsql As String
Dim qd As QueryDef
Dim wkODBCDirect As Workspace
Dim strsql2 As String
Dim qd2 As QueryDef
'Connection String
scn = "ODBC;DRIVER=SQL SERVER;SERVER=BOB-MDTNZL7OFKX;DATABASE=pubs"
Set cn = OpenConnection("", dbDriverComplete, False, scn)
'Creates the record set
Set rs = cn.OpenRecordset("Select * From sales", dbOpenDynaset)
cboStoreID = rs![stor_id]
End Sub
Any help would be really appreaciated
Thank you
I am trying to get this code to work, but it keeps stoping on the cn (Set cn = OpenConnection("", dbDriverComplete, False, scn)) line for the connection to the SQL Server. The error says that the opperation is not supported by this type of object. I got this from a book, As usal I think they are leaving some code out. And I need a way to do this through ODBC, because that is what the company wants.
Here is my code:
Private Sub Form_Load()
Dim db As Database
Dim cn As Connection
Dim rs As Recordset
Dim rs2 As Recordset
Dim scn As String
Dim strsql As String
Dim qd As QueryDef
Dim wkODBCDirect As Workspace
Dim strsql2 As String
Dim qd2 As QueryDef
'Connection String
scn = "ODBC;DRIVER=SQL SERVER;SERVER=BOB-MDTNZL7OFKX;DATABASE=pubs"
Set cn = OpenConnection("", dbDriverComplete, False, scn)
'Creates the record set
Set rs = cn.OpenRecordset("Select * From sales", dbOpenDynaset)
cboStoreID = rs![stor_id]
End Sub
Any help would be really appreaciated
Thank you