473,324 Members | 2,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

RecordSet as Record Source

Lyn
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 I
create a RecordSet (using ADO) in the parent form. The RecordSet object is
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 parent
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 such
that it is not recognised across modules? Is there a better way to achieve
this anyway?

--
Cheers,
Lyn.
Nov 13 '05 #1
2 9629
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" <lh******@ihug.com.au> wrote in message
news:cs**********@lust.ihug.co.nz...
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 I create a RecordSet (using ADO) in the parent form. The RecordSet object is 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 parent 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 such that it is not recognised across modules? Is there a better way to achieve this anyway?

--
Cheers,
Lyn.

Nov 13 '05 #2
Lyn
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" <ma********@nospam.com> wrote in message
news:LW*****************@newsread3.news.atl.earthl ink.net...
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" <lh******@ihug.com.au> wrote in message
news:cs**********@lust.ihug.co.nz...
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

I
create a RecordSet (using ADO) in the parent form. The RecordSet object

is
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

parent
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

such
that it is not recognised across modules? Is there a better way to

achieve
this anyway?

--
Cheers,
Lyn.


Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Justin Koivisto | last post by:
I am trying to create a report that displays a name of an advertising source and count of the number of times it was hit between certain date ranges. The data is split between two different...
4
by: steph | last post by:
Hi, A question regarding Access 2002: I've got a form which should be displayed in Form View and in Datasheet View. But I want to use a different record source for each view. That means, when...
6
by: ApexData | last post by:
I have 2 tables: Table1 and Table2. Neither one has a primary key because each table will only have 1-record. My form is a SingleForm unbound with tabs (my desire here). Using this form, in...
17
by: kkk1979 | last post by:
I have been using access as front end and SQL as Back end. I need help in generating an access report, by using a stored procedure with input parameters as record source. I tried the following...
1
by: Peter Herath | last post by:
I have created a report using sample codes taken by the forum. one problem is that the report displays the field/column names in the table in columnar format(field names display in rows.) but i want...
1
by: kjworm | last post by:
Greetings all, I have a main form that does not have a record source. On that main form is a combobox that looks up values from the main table and is based off of a stored query. I also have a...
1
by: jglabas | last post by:
For a report, I am using a query as my record source. The query produces 5 columns by 3272 records. The data in columns 1 & 2 (“Objective” and “Rating”) repeats every 409 records The data for...
1
by: thread | last post by:
Hi i built a form that getting dynamic SQL string,the SQL string is placed in the record source when the form is opened. i notice when trying to reduce some proccess time from the form that it...
30
by: CD Tom | last post by:
I found Stephen Lebans modReportToPDF and have been trying to get it to work in my application. I've downloaded his database and when I run his test it works fine. I then added it to my application...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.