ahmedjamalaboelez
Ahmed J. Aboelez
- Local time
- Yesterday, 21:50
- Joined
- Feb 25, 2015
- Messages
- 79
Hi,
I'm Using following code to connect to sql server , how could assign my recordset as ( Continious form Record Source ),
connection is successful But I need help in recordset!
I'm Using following code to connect to sql server , how could assign my recordset as ( Continious form Record Source ),
connection is successful But I need help in recordset!
Code:
Private Sub Command0_Click()
Dim cnn As ADODB.Connection
Dim rsData As ADODB.Recordset
Dim strSQL As String
strSQL = "SELECT * FROM USERS"
Set cnn = New ADODB.Connection
cnn.Provider = "SQLOLEDB.1"
cnn.ConnectionString = "driver={SQL Server};" & _
"server=192.168.1.156;uid=sa;pwd=123654;database=testdb"
Set rsData = New ADODB.Recordset
cnn.Open
If cnn.State = adStateOpen Then
MsgBox "connected server"
DoCmd.OpenForm "test1" ' here is the error message i need help to assign this recordset (rsData as form record source)
Set Forms![test1].Recordset = rsData
cnn.Close
rsData.Close
Else
MsgBox "Not connected server"
Exit Sub
End If
End Sub
Last edited by a moderator: