code
Sub Get_Accountno()
Dim Conn as ADODB.Connection 'Connection
Dim Rs as ADODB.Recordset 'Recordset
Dim strQuery As String 'Command
Set Conn = New ADODB.Connection
With Conn
.CursorLocation = adUseClient
.ConnectionString= "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\MyPath\myDatabase.mdb"
.Open
End With
strQuery = "SELECT Accountno FROM tblTable " & _
"WHERE Username = 'BillK'"
Set Rs = New ADODB.Recordset
With Rs
Set .ActiveConnection = Conn
.CursorType = adOpenStatic
[b].Open strQuery, Conn[/b]
End With
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.