[AccessD] Setting a forms recordsource using ADO

jeffrey.demulling at usbank.com jeffrey.demulling at usbank.com
Thu Mar 6 12:57:00 CST 2003


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030306/7af17bd8/attachment.html>


More information about the AccessD mailing list