[AccessD] Setting a forms recordsource using ADO

MartyConnelly martyconnelly at shaw.ca
Thu Mar 6 23:19:00 CST 2003


Here is a sample unbound form have a look around this site for other samples
http://www.rogersaccesslibrary.com/download.asp?SampleName='UnboundSQL.mdb'
In code just change the DAO openrecordset  to your ado recordset

Set rsCust = D.OpenRecordset(strSQL, DB_OPEN_DYNASET)

Me!ACCOUNT = rsCust("ACCOUNT")

jeffrey.demulling at usbank.com wrote:

>
> I have the current code for an on click event:
>
> Dim cn As New ADODB.Connection
> Dim rs As New ADODB.Recordset
> Dim strConnectionString As String
> Dim cmdText As String
> Dim fld As ADODB.Field
>
>
> cn.Provider = "SQLOLEDB"
> cn.Properties("Data Source") = <my server here>
> cn.Properties("Initial Catalog") = <my database here>
> cn.Properties("User ID") = <my user id is here>
> cn.Properties("Password") = <my password is here>
> cn.Open
>
>
> cmdText = "Select * From tblregions"
>
> rs.Open cmdText, cn
>
> Me.RecordSource = rs.GetRows
>
> rs.MoveFirst
>
> Do Until rs.EOF
>     MsgBox rs.Fields("Number")
>     rs.MoveNext
> Loop
>
> This code allows me to Loop through the recordset and see the values 
> in a message box.
>
> Now what I want to do is place the information on a form (continous 
> would be fine for now).
>
> If any one can help me with this ADO stuff I would appericate it very 
> much, as I am just now getting to play with it.
>
> Thanks!!!
>
> rs.Close
> End Sub 






More information about the AccessD mailing list