Is it possible to create a Recordset without a Table or Query? (1 Viewer)

prabha_friend

Prabhakaran Karuppaih
Local time
Today, 10:04
Joined
Mar 22, 2009
Messages
785
Yes. You read it right. Without any objects. Assume the Database is empty but only with some class modules which needed it's instances to be bound to a recordset. possible?
Please confirm. Thank You.
 

LarryE

Active member
Local time
, 21:34
Joined
Aug 18, 2021
Messages
592
Well, I guess since there are no records, then you can't define a recordset. So, the answer is no.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 05:34
Joined
Jul 9, 2003
Messages
16,282
Lookup disconnected record sets
 

GPGeorge

Grover Park George
Local time
, 21:34
Joined
Nov 25, 2004
Messages
1,889
Yes. You read it right. Without any objects. Assume the Database is empty but only with some class modules which needed it's instances to be bound to a recordset. possible?
Please confirm. Thank You.
Sometimes, the way a question is presented leads to more questions before we ever get to answers. Like this one.

WHY do you want to do this? What is the goal? What is the environment where it'll be implemented? What kinds of values will be put into this "recordset"? From where will they be obtained? That kind of question.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 05:34
Joined
Jul 9, 2003
Messages
16,282
Lookup disconnected record sets

I found a link:-


I haven't done it but I suspect you would be able to add items to the the disconnected recordset with VBA code. like I said, not something I've done but something I might like to try one day!
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
, 23:34
Joined
Feb 28, 2001
Messages
27,200
This leads to a complex problem. An ADO method exists to create a disconnected recordset, but the appropriate method creates an object. The object is not linked to much, but a disconnected recordset IS an object.

So in the really nit-picking viewpoint, the answer to your lead-in question is NO - because if your class modules need binding to a recordset, a recordset MUST exist for the binding to occur. But there is nothing wrong with the idea that the instantiation code of the object could create its own object if you don't happen to supply one. If that is not adequate, we would need to know more about the requirement.
 

prabha_friend

Prabhakaran Karuppaih
Local time
Today, 10:04
Joined
Mar 22, 2009
Messages
785
Sometimes, the way a question is presented leads to more questions before we ever get to answers. Like this one.

WHY do you want to do this? What is the goal? What is the environment where it'll be implemented? What kinds of values will be put into this "recordset"? From where will they be obtained? That kind of question.
Assume there are tables called [Plans],[Tasks] and [Plan_Tasks] respectively
Usually what we do is we select the plan_id and Task_id in the [Plan_Tasks] Table
What if the user wants the Developer to show all the Plans to already pre-entered into the Plan_Tasks table whenever a new task is generated and also wants a checkbox to be ticked by default but can be unticked if the user doesn't want to attach that particular task in that plan. Currently I have created table called Plan_Tasks_Menu to hold the checkbox value. Actually I feel that the Menu table is not actually need to present in the Database. That's why I feel better if I create a class to instanciate just to hold the true/false for the Tasks in the Memory.
 

LarryE

Active member
Local time
, 21:34
Joined
Aug 18, 2021
Messages
592
Yes, you might be able to create a table with a standalone Public Function VBA code routine, and then create a recordset from the table. You could import data into it with VBA code too. I didn't think that was what was asked, but yes you could most likely do those things. I've created tables and queries using VBA and imported data, but have never attempted to create a table using VBA with no tables already created.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
, 23:34
Joined
Feb 28, 2001
Messages
27,200
Assume there are tables called [Plans],[Tasks] and [Plan_Tasks] respectively
Usually what we do is we select the plan_id and Task_id in the [Plan_Tasks] Table
What if the user wants the Developer to show all the Plans to already pre-entered into the Plan_Tasks table whenever a new task is generated and also wants a checkbox to be ticked by default but can be unticked if the user doesn't want to attach that particular task in that plan. Currently I have created table called Plan_Tasks_Menu to hold the checkbox value. Actually I feel that the Menu table is not actually need to present in the Database. That's why I feel better if I create a class to instanciate just to hold the true/false for the Tasks in the Memory.

If ALL you are doing is remembering some T/F flags, look into TempVars as a way to hold up to 255 such flags, each of them named and thus individually accessible, but not as part of a recordset.
 

GPGeorge

Grover Park George
Local time
, 21:34
Joined
Nov 25, 2004
Messages
1,889
Ah. Thanks. Well, there are two ways to look at this.

One, the general principle is that we should NOT add Plan_Tasks at all until we actually request them. That's the reverse of what you are saying. You add them and then delete the ones you don't want.

I prefer that approach.

However, you COULD do this with a disconnected recordset into which you first add all of the tasks and then remove the ones you decide you don't want. But that still would require "something" to show to the user to let them pick the items to delete. And that's going to be a form, and that means a recordset as the form's recordsource. That could be the initial recordset created as a disconnected recordset.

Argghhh. All of this makes me a bit uneasy. I have a general principle about designing and implementing relational database applications:

KISS-- or "Keep It Simple Sir".

Why go to all the trouble of writing up a wad of code to do all that? Why not present the user a subform bound to the Plan_Tasks table and let them add only the items they want and none of the items they don't want?
 

prabha_friend

Prabhakaran Karuppaih
Local time
Today, 10:04
Joined
Mar 22, 2009
Messages
785
My Proposal.png

My Proposal
His Expectation.png

His Expectation. Sorry. I cannot convince him. He is adamant.
 

isladogs

MVP / VIP
Local time
Today, 05:34
Joined
Jan 14, 2017
Messages
18,243
In case it helps, have a look at my example app:

It was written for a different reason but uses disconnected ADO recordsets so there are no linked tables in the FE
 

GPGeorge

Grover Park George
Local time
, 21:34
Joined
Nov 25, 2004
Messages
1,889
View attachment 98788
My Proposal View attachment 98789
His Expectation. Sorry. I cannot convince him. He is adamant.
Well, I once had a client like that. We were not good friends, just in a business relationship that ended when the project ended.

If you want to try the Disconnected Recordset approach, that's probably more elegant.

However, the way I would finesse this is to go ahead and add the "bonus" records in the Task_Plan table, but DISPLAY them in this subform in a query that has a second helper table joined in it. The helper table has one field, the "Yes/No" for "Select".
When the user clicked the check box next to a record that was to be removed, I ran a delete query against the table--here that would be the Task_Plan table for that item. Not so elegant, I agree, but it worked and didn't take hours of coding to implement.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 05:34
Joined
Sep 12, 2006
Messages
15,659
Assume there are tables called [Plans],[Tasks] and [Plan_Tasks] respectively
Usually what we do is we select the plan_id and Task_id in the [Plan_Tasks] Table
What if the user wants the Developer to show all the Plans to already pre-entered into the Plan_Tasks table whenever a new task is generated and also wants a checkbox to be ticked by default but can be unticked if the user doesn't want to attach that particular task in that plan. Currently I have created table called Plan_Tasks_Menu to hold the checkbox value. Actually I feel that the Menu table is not actually need to present in the Database. That's why I feel better if I create a class to instanciate just to hold the true/false for the Tasks in the Memory.

Without looking too closely, this may be a design - table structure issue. If your structure doesn't lend itself to what users want (or need) then either change the structure so that you can, or decide that you can't provide the required facility.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 00:34
Joined
May 21, 2018
Messages
8,546
Yes. You read it right. Without any objects. Assume the Database is empty but only with some class modules which needed it's instances to be bound to a recordset. possible?
Please confirm. Thank You.
Yes you most certainly can, and yes there are good reasons to do so. See example.

That example is pretty similar to what you are saying. I am not saying it is a good idea to do it that way, but in theory it can be done.
Usually what we do is we select the plan_id and Task_id in the [Plan_Tasks] Table
What if the user wants the Developer to show all the Plans to already pre-entered into the Plan_Tasks table whenever a new task is generated and also wants a checkbox to be ticked by default but can be unticked if the user doesn't want to attach that particular task in that plan. Currently I have created table called Plan_Tasks_Menu to hold the checkbox value. Actually I feel that the Menu table is not actually need to present in the Database. That's why I feel better if I create a class to instanciate just to hold the true/false for the Tasks in the Memory
 
Last edited:

MajP

You've got your good things, and you've got mine.
Local time
Today, 00:34
Joined
May 21, 2018
Messages
8,546
The answer is LINQ
No it is not even close. There is no support to LINQ in VBA. If you are talking VB.NET (VB) then you can easily build a disconnected recordset. Not sure where you think LINQ comes to play.
 

Users who are viewing this thread

Top Bottom