Solved

How to make a Data Control a variable name??

Posted on 1998-07-28
2
128 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

756 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