[AccessD] Bind Form to RecordSet

Arthur Fuller fuller.artful at gmail.com
Sun Feb 24 12:55:32 CST 2013


Ah, Susan! My lovely little duck! I didn't even look up the link you
provided. I knew at once that you were right. A quick edit and presto.

Thanks!

A.


On Sun, Feb 24, 2013 at 1:41 PM, jack drawbridge <jackandpat.d at gmail.com>wrote:

> Arthur,
>
> I would try
> Me.Recordsource = strSQL
>
> rather than  rs
>
> Just a guess.
>
> On Sun, Feb 24, 2013 at 1:16 PM, Arthur Fuller <fuller.artful at gmail.com
> >wrote:
>
> > I'm playing around with ways to do this but am running into a problem.
> >
> > The form_open looks like this:
> >
> > <vba>
> > Dim db As DAO.Database
> > Dim rs As DAO.Recordset
> > Dim strSQL As String
> >
> > Set db = CurrentDb
> > strSQL = "SELECT * FROM Volunteers WHERE LastName IS NOT NULL " & _
> >          "ORDER BY LastName"
> >
> >
> '----------------------------------------------------------------------------------------------
> > ' Open the recordset
> >
> >
> '----------------------------------------------------------------------------------------------
> > Set rs = db.OpenRecordset(strSQL)
> >
> > With rs
> >     If .EOF And .BOF Then
> >         MsgBox "No records returned."
> >     Else
> >         .MoveFirst
> >         While Not .EOF
> >             Debug.Print rs("VolunteerID"), rs("LastName")
> >             .MoveNext
> >         Wend
> >     End If
> > End With
> >
> > MsgBox "Setting new record source"
> > Debug.Print "Setting new record source"
> >
> > 'Here's where I get busted:
> > 'Set Me.RecordSource = rs
> >
> > rs.Close
> > Set rs = Nothing
> > End Sub
> > </vba>
> >
> > I read something from microsoft on how to bind a form to a recordset but
> > the example was bound to a SQL Server db, and I wanted to keep it simple
> -
> > just create a local recordset and then assign it to the recordsource.
> >
> > So I'm confused. Every previous time I've altered RecordSource it's been
> by
> > substituting a string. But the code in the MS example uses exactly the
> > syntax that failed me above.
> >
> > Any suggestions, people?
> >
> > --
> > Arthur
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>



-- 
Arthur
Cell: 647.710.1314

Prediction is difficult, especially of the future.
  -- Niels Bohr


More information about the AccessD mailing list