Hi everyone,
I have used the below code in Access2003 and it works fine. Now I tried the same in Access2007 by creating a new project but I get an error "user-defined type not defined" in line 4.
Is there anything I have to do first before coding this?
Private Sub Command0_Click()
On Error GoTo Err_Command0_Click
Const conObjStateClosed = 0
Dim dstUsers As ADODB.Recordset
Dim dstMembers As ADODB.Recordset
Dim cnn As ADODB.Connection
Dim xCurrentUser As String
Dim xPassword As String
xCurrentUser = "veriajeth"
xPassword = "12345"
Set cnn = New ADODB.Connection
cnn.Open "Provider=SQLOLEDB.1;" & _
"Server=192.168.0.237;Initial Catalog=NNetSales", xCurrentUser, xPassword
Set dstUsers = New ADODB.Recordset
dstUsers.ActiveConnection = cnn
dstUsers.CursorType = adOpenKeyset
dstUsers.LockType = adLockOptimistic
dstUsers.Open "Select * From Employee", , , , adCmdText
dstUsers.MoveFirst
MsgBox dstUsers("EmployeeName")
dstUsers.Close
Set dstUsers = Nothing
Exit_Command0_Click:
Exit Sub
Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click
End Sub
_________
Thanks.
I have used the below code in Access2003 and it works fine. Now I tried the same in Access2007 by creating a new project but I get an error "user-defined type not defined" in line 4.
Is there anything I have to do first before coding this?
Private Sub Command0_Click()
On Error GoTo Err_Command0_Click
Const conObjStateClosed = 0
Dim dstUsers As ADODB.Recordset
Dim dstMembers As ADODB.Recordset
Dim cnn As ADODB.Connection
Dim xCurrentUser As String
Dim xPassword As String
xCurrentUser = "veriajeth"
xPassword = "12345"
Set cnn = New ADODB.Connection
cnn.Open "Provider=SQLOLEDB.1;" & _
"Server=192.168.0.237;Initial Catalog=NNetSales", xCurrentUser, xPassword
Set dstUsers = New ADODB.Recordset
dstUsers.ActiveConnection = cnn
dstUsers.CursorType = adOpenKeyset
dstUsers.LockType = adLockOptimistic
dstUsers.Open "Select * From Employee", , , , adCmdText
dstUsers.MoveFirst
MsgBox dstUsers("EmployeeName")
dstUsers.Close
Set dstUsers = Nothing
Exit_Command0_Click:
Exit Sub
Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click
End Sub
_________
Thanks.