473,378 Members | 1,495 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,378 software developers and data experts.

Dynamically Name Object for Reference

zmbd
5,501 Expert Mod 4TB
This is driving me nuts.
I'd like to use a loop to set the reference to about a dozen objects.
The recordsets are also able to be named by appending the loop count to the proper points in the code.

What I am doing is normalizing some old data.
In the past I would just simply hardcode
Expand|Select|Wrap|Line Numbers
  1. SET data_topic_1 = (object_1)
  2. SET data_topic_2 = (object_2)
  3. '(...)
  4. SET data_topic_n = (object_n)
What I'd like to do:
Expand|Select|Wrap|Line Numbers
  1. 'need these public for the forms and modules to work 
  2. 'with while importing into the proper fields
  3. 'and updating information.
  4. Public data_archive_1 As dao.database
  5. Public data_archive_2 As dao.database
  6. Public data_topic_1 As dao.recordset
  7. Public data_topic_2 As dao.recordset
  8. Public data_topic_3 As dao.recordset
  9. Public data_topic_4 As dao.recordset
  10. 'add another 15... 
  11. 'to finally get to...
  12. Public data_topic_19 As dao.recordset
  13.  
  14.  
  15. sub setuptopicrecordsets()
  16.    Dim x As Integer
  17.    Dim zstrRsName As string
  18. '...air code...
  19. 'set up the references to the other database files etc..
  20. '
  21. 'setup for data retrieval
  22.    for x = 1 to 19
  23.       zstrRsName = "data_topic_" & x
  24.       set zstrRsName = ....(recordsetstring)....
  25.    next x
  26. '
  27. '...air code...
  28. '
of course I get a need object error at the set
I thought I had done something like this in the past. However, I just can't seem to remember what I did to get this to work, I can't seem to locate the old database (which is why I'm (re)doing this today," and hardcoding 19 references just doesn't sound very fun today with all of the other crud that has hit my lab.

Given the amount of time I've spent on this, I could have hardcoded the entire lot; however, at this point it's the principal of the thing...
[~.~] grr... dog/w/bone ... grr [~.~]




-when it rains it pours-




-z
Oct 22 '14 #1
6 1742
twinnyfo
3,653 Expert Mod 2GB
Hey Z,

I think I understand what you're trying to do. But, I wish I knew how you were planning to use the recordsets individually and maybe it would make more sense.

One of my thoughts was to use an String Array to store the 19 data topics, then just cycle through using one recordset (Set it to the new data set each time you loop through x).

Not quite sure if that is making any sense. I can kinda see it in my head what I am thinking of doing, but still not sure what the recordset is supposed to look like from your end.

We can fuddle through it together....
Oct 22 '14 #2
Seth Schrock
2,965 Expert 2GB
Rabbit helped me with something similar in this thread: Looping through groups of conrols. Couldn't you change the collection to contain recordsets?
Oct 22 '14 #3
dsatino
393 256MB
I would definitely use an array and loop through those.
Oct 23 '14 #4
zmbd
5,501 Expert Mod 4TB
I'll have to look at the collection thing, I think that's what I did the last time using the counter as the key-value.

The SQL string is easy enough to write by counter, which is what I did, storing the string in the table and then pulling that value into the open-recordset command while setting the reference.

@TF: In short, and I have to gloss over some things for the company...
A mad man many years ago made a table for each sample sortof:
[tbl_customerid_sampleid] in database files named [yyyymmdd] and then he had a database file that listed every sample_id and which database file. The individual viewed databases like worksheets... it used to be fun to watch him pull the data.

yummy-yummy-yummy

Now this wouldn't be too bad, I have a database with multiple backends... which backend is connected depends on the user profile, provided there were some actual relationships in the system of files. What we have to do with these old archives is pull the customer id then build queries in the sample log which then lets us pull the information out of the other databases files...

Now this is where I come in....

For simple queries, I take all of these files, bring them in as recordsets, select the related fields between the recordsets so taking a bunch of unrelated files and making a relational database via frontend.

For more complex queries, I pull the records apart and store field names as record entries etc...
Oct 23 '14 #5
twinnyfo
3,653 Expert Mod 2GB
What...
A...
Disaster!
Oct 27 '14 #6
zmbd
5,501 Expert Mod 4TB
Oh, TwinnyFo, it is actually worse than I've given... I've greatly simplified the details.

The person believed that sharing knowledge was tantamount to losing ones position; thus, he'd never share how he would make the reports etc... While he was out on vacation, instead of bothering him I looked at what was going on in the databases and a day later pulled the reports and started the demystification of the data-pools. He was not very happy with me. Anyway, he has moved on and I've inherited the mess... then we were bought out by a huge company so the mess isn't as important as it use to be - just every now and again, we need something.

Thnx
Oct 27 '14 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: kon george | last post by:
Can somebody assist. I build this code on a dev laptop and copied across the entire code to a Windows 2003 server with 1.1 framework. It is basic ASP.NE T that uses web service for SQL Server...
9
by: Moe Sizlak | last post by:
Hi There, I am trying to write the selected value of a listcontrol when a button is clicked and I keep getting the error "object not set to a reference of an object". The libox itself is in a...
3
by: Adam | last post by:
We have a web site that uses .vb for the web pages and .cs for a class module. We are getting the error in .NET 2.0 and VS 2005 beta 2. It does work with .NET 1.1. When trying to access a page...
2
by: -BA- | last post by:
Hi! I wonder if it is possible to dynamically name a object (e.g. checkbox, combox etc.) during runtime. I know I can create a object during runtime like this: Me.MyLabel = New Label...
8
by: CES | last post by:
All, I'm sorry but I still don't get this!! I'm trying to use a variable that is passed into a function to to dynamically name an instance of an Object(). I've created a Timer() Object that seems...
7
by: Andrew Mercer | last post by:
I am getting the above error when attempt to set the src, height and width of an iframe in C# code. I am using this as an attempt to dynamically alter the image displayed in the iframe tag of an...
10
by: Arpan | last post by:
Consider the following code that adds a table to a DataSet dynamically: <script runat="server"> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) 'Create an empty DataSet Dim dSet As...
10
by: Jess | last post by:
Hello, If I create a temporary object using a dynamically created object's pointer, then when the temporary object is destroyed, will the dynamically created object be destroyed too? My guess...
3
by: =?Utf-8?B?a2VubnltY2U=?= | last post by:
Hi, I'm probably being somewhat dim here and missing something obvious, but I'm trying to dynamically create a text box and then retrieve its value after postback. Partial Public Class...
3
by: Asprisa | last post by:
Hi Guys, We have a aspx page on a web server that was created by someone who has now left our company which for some reason just started throwing an error, i have been looking into reasons for...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.