S
Santiago Gomez
Hello all,
I am trying to set the recordsource of a subform with vba using a connection
string, but I get an error.
I think I have the wrong syntax on the last line. (I also tried
Me.Recordset = rst)
Can anyone point me in the right direction?
thanks
Private Sub Command2_Click()
Dim oConn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim strSQL As String
oConn.Open "Provider=sqloledb;" & _
"Network Library=DBMSSOCN;" & _
"Data Source=156.235.235.212,1433;" & _
"Initial Catalog=Advantage;" & _
"User ID=username;" & _
"Password=password"
strSQL = "SELECT Table1.Field1, Table1.Field2 FROM Table1;"
rst.Open strSQL, oConn
me.recordsource = strSQL
End Sub
I am trying to set the recordsource of a subform with vba using a connection
string, but I get an error.
I think I have the wrong syntax on the last line. (I also tried
Me.Recordset = rst)
Can anyone point me in the right direction?
thanks
Private Sub Command2_Click()
Dim oConn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim strSQL As String
oConn.Open "Provider=sqloledb;" & _
"Network Library=DBMSSOCN;" & _
"Data Source=156.235.235.212,1433;" & _
"Initial Catalog=Advantage;" & _
"User ID=username;" & _
"Password=password"
strSQL = "SELECT Table1.Field1, Table1.Field2 FROM Table1;"
rst.Open strSQL, oConn
me.recordsource = strSQL
End Sub