Re: data is not getting populated

From: Dirk Goldgar (dg_at_NOdataSPAMgnostics.com)
Date: 03/25/04


Date: Thu, 25 Mar 2004 01:53:16 -0500


"mgarg" <anonymous@discussions.microsoft.com> wrote in message
news:BFAFEEA7-8D27-4331-960A-B29253AFCD46@microsoft.com
> Hi all,
> I am using sql server as backend and I am creating a form in Access.
> This form contains several text boxes which needs to be populated
> with data. this data is coming from table pass.
>
> Following code does not give any error but it does not display the
> data either. when i go in debug mode the rst get populated with the
> right value. any help would be appreacited. thanks a lot
>
> Private Sub Form_Load()
>
> Dim strSql As String
> Dim conString As String
> Dim con As ADODB.Connection
> Dim rst As ADODB.Recordset
>
> strSql = "SELECT Degree FROM pass where User_Name='mgarg'"
> Set con = New ADODB.Connection
> conString = "Driver={SQL Server};Server=;DataBase=;Uid=;Pwd=;"
> con.Properties("Prompt") = adPromptAlways
>
> con.ConnectionString = conString
> con.Open
>
> Set rst = New ADODB.Recordset
>
> rst.Open strSql, con, adOpenForwardOnly, adLockReadOnly
>
> Do While Not rst.EOF
> Degree.ControlSource = rst.Fields("Degree")
> rst.MoveNext
> Loop
>
> rst.Close
> con.Close
>
> End Sub

Is this in a regular Access .mdb file, or in and Access Data Project?
It sounds as though you are trying to bind your form to this SQL Server
table. If it's an .mdb file, why don't you just create a linked table
(linked to the SQL-S table) and set your form's recordsource to the
linked table, or a query of it?

-- 
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)


Relevant Pages