Dynamic Recordset & Array

raystownlaura

Registered User.
Local time
Today, 10:42
Joined
Apr 16, 2010
Messages
22
I'd like to create a recordset that is NOT based on a table or query, but rather an array of values. I would love some assistance by way of code because I have always struggled to understand how to use arrays.

Here's what I need to do. User inputs a Begin Date and an End Date into a form. I'd like to

1. Create an array of the dates included between and including the user input begin and end dates.

2. Fill a dynamic recordset that is not based on a table or query, rather the values in the array that I created in step one.

Any help would be very much appreciated!
 
You don't need to create an array for what you need. It would just be another container to hold dates which you don't need.

Just create a loop that starts from your start date and loop through until you hit the date end.

In the loop add your dates to the temporary recordset.

The array is just redundant for you what you are trying to achieve.
 
You can make a fabricated recordset. It has no connection, is not bound to a table.

Dim rs As New ADODB.Recordset

rs.Fields.Append "ID", adBigInt
rs.Fields.Append "Name", adBSTR

rs.Open
rs.AddNew
rs!ID = 1
rs!Name = "Bob"


rs.MoveFirst
MsgBox rs!Name

rs.AddNew
rs!ID = 2
rs!Name = "Dan"

rs.MoveLast
MsgBox rs!Name

Set rs = Nothing
 
That seems to be a lot more trouble than its worth. Once you have the start date and the end date you can calculate any date in the middle on the fly. Maybe there is a specific reason you need a recordset but withouth knowing what you are going to do with it I agree with ions.
 

Users who are viewing this thread

Back
Top Bottom