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

Using Array Within For Statement to Call Dynamic Procedure

Hi,

I have an IF..Then statement that I am using to determine which procedure to Call. Within the "else" section, I want to use a For..Next coding to loop through 3 different "call procedures". Here is what I have so far:


Dim arrCall As Variant
ReDim arrCall(2)

arrCall(0) = "GetData1"
arrCall(1) = "GetData2"
arrCall(2) = "GetData3"

If optVersion.Value = True Then

Call GetProcedure1

Else

For i = 0 to 2

Call arrCall(i)

Next

End If

But it keeps giving me the error: Sub or Function needed.

So basically, I want the For..Next loop to go through each "CallData". I'm not sure what I'm doing wrong.

Thanks.
Oct 26 '07 #1
3 3160
kadghar
1,295 Expert 1GB
arrCall is a variable, not a function or sub, you cannot call it

i think you want to call GetData1, GetData2 and GetData3, call them one by one:
else
call getdata1
call getdata2
call getdata3
end if

HTH
Oct 26 '07 #2
kadghar
1,295 Expert 1GB
oh, i forgot, it'll be good if you say what version you're using. In VBA is possible to do it with strings.

lets say you have a sub called "Test1"

Expand|Select|Wrap|Line Numbers
  1. dim Str1 as string
  2.  
  3. str1="Test1"
  4.  
  5. application.run(str1)
this will call the sub Test1 :)

HTH
Oct 26 '07 #3
9815402440
180 100+
hi

first make the proceedures you are calling public.

then use CallByName function
e.g. CallByName array(0)


regards
manpreet singh dhillon Hoshiarpur
Oct 27 '07 #4

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

Similar topics

4
by: Michael Trosen | last post by:
Hi Everyone, I hope someone can help, I'm pretty new to pro*c programming. I have the following application setup: a pro*c program calls a stored procedure and recieves a cursor back: the...
7
by: Alex Vorobiev | last post by:
hi there, i am using sql server 7. below is the stored procedure that is giving me grief. its purpose it two-fold, depending on how it is called: either to return a pageset (based on page...
18
by: Robin Lawrie | last post by:
Hi again, another problem! I've moved from an Access database to SQL server and am now having trouble inserting dates and times into seperate fields. I'm using ASP and the code below to get the...
2
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
10
by: Rick Palmer | last post by:
I have an app I'm working on that will allow a user to run one of 5 reports. The report names are in a combobox on my form. I have a sub defined for each report that has the exact same name as is...
2
by: Rajat Katyal | last post by:
Hi: I prepare the statement for execution as follows: PREPARE query(text) as SELECT count(*) FROM transform_customer_billing where inv_no = $1; The problem is Iam not able to execute this...
1
by: deepdata | last post by:
Hi, I am trying to fetch data from db2 (express version) database by calling stored procedure. I have tried to use both cursor and for loop but still i am getting error. --======Start...
0
ADezii
by: ADezii | last post by:
Generally, the number of Arguments in a Procedure Call must be the same as in the Procedure Specification. If a Procedure requires 3 Arguments in its Specification, when calling the Procedure you...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.