Solved

How to make a Data Control a variable name??

Posted on 1998-07-28
2
130 Views
Last Modified: 2010-05-03
I have a form with several data controls to produce combo boxes that have lists from various tables to facilitate data input.  I'd like to try and shorten some of the code for queries.  I've got a select case statement started, but what I'd like to do is something like:

  datVariable = Data1

  RecCount(Index) = datVariable.Recordset.Recordcount
  (where Index is from a control array)

I don't recall the exact code at the moment, but I think you get the idea.

How can I make the data control a variable?  I've tried using string and variant but with no success.

Help would be greatly appreciated.

-- Stacey --
0
Comment
Question by:s033slb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
anthonyc earned 10 total points
ID: 1467033
dim x as object

set x = data1
reccount(index) = x.recordset.recordcount


You can also do this in your select case

select case 5
case 1
   szData = "data1"
case 2
   szData = "data2"
case 5
   szData = "data5"
end select

reccount(index) = me.controls(szdata).recordset.recordcount
0
 

Author Comment

by:s033slb
ID: 1467034
This worked great!!

Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question