| re: RecordSet as Record Source
Thanks for the quick response. I should have mentioned that I am using
Access 2003, but I was unaware of the RecordSet property -- I am looking
into that now. And I will try doing this in Open and see how it goes.
I was passing the name of the recordset as a string to the Record Source
property.
And actually, I am doing quite a bit more in the parent form. I already
have the recordset created and I was looking for a way to avoid having to
create it again in the other form.
Anyway, I will study your advice and see how I go.
Thanks again.
--
Cheers,
Lyn.
"MacDermott" <macdermott@nospam.com> wrote in message
news:LWrId.5430$rp1.1394@newsread3.news.atl.earthl ink.net...[color=blue]
> Coupla things here.
> First, RecordSource is a string property which gives the name of the table
> or query on which the form's data is based, so you can't set a string
> property to a recordset.
> Second, if you're using Access 2000 or later, forms have a Recordset
> property you can set, which will probably do what you want.
> Third, I'd suggest using the form's Open event, rather than Load, because
> Load doesn't fire until after the pre-defined recordset is loaded, so it
> would have to re-load the data. By using Open, you can change the
> recordset
> before it's loaded.
> Fourth, if you're just limiting the data in the form, you can build a
> criteria string in the code on the main form and pass that as an argument
> of
> DoCmd.OpenForm. No need to build an extra recordset.
>
> HTH
>
> "Lyn" <lhancock@ihug.com.au> wrote in message
> news:cstf4q$cg0$1@lust.ihug.co.nz...[color=green]
>> If I have a form where the RecordSource property is set to the name of a
>> table, then on opening the SingleForm form I can cycle through all the
>> records in the table one at a time via Next and Previous buttons on the
>> form.
>>
>> However, I only want to cycle through a subset of the table. I have a
>> parent form which inputs selection criteria. With the selection criteria[/color]
> I[color=green]
>> create a RecordSet (using ADO) in the parent form. The RecordSet object[/color]
> is[color=green]
>> declared as Public, so it should be accessible in all modules.
>>
>> I feel that when loading the main form from the parent form, I should be
>> able to set its RecordSource property to the Public RecordSet so that the
>> form sees only the selected subset of records. I do this through the
>> Load
>> event.
>>
>> But when I do this, I get an error message that the RecordSet is not
>> recognised as valid Record Source. The recordset remains open in the[/color]
> parent[color=green]
>> form until the form is closed or another set of criteria is input.
>>
>> What am I doing wrong? Is it not valid to have a recordset as the Record
>> Source in a form? Or am I not declaring the recordset object correctly[/color]
> such[color=green]
>> that it is not recognised across modules? Is there a better way to[/color]
> achieve[color=green]
>> this anyway?
>>
>> --
>> Cheers,
>> Lyn.
>>
>>[/color]
>
>[/color] |