473,396 Members | 2,052 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,396 software developers and data experts.

Dynamic modification of code

I am relatively new to VBA and have roots in TCL and 'C'. I was trying to
generalize a program by stuffing column names in an array and then using
array elements in a statement. For example:

Dim I As Integer
Dim Array(2) As String
Array(0) = "Contract Date"
Array(1) = "Paid Date"
Array(2) = "Some other date"

For I =0 To 2
If IsNull(rstTable!Array(I)) Then
Do Something
End If
Next I

Well, clearly it isn't working. I get a message saying that
rstTable!Array(I) is not a member of the group.

Is it possible to construct such a loop in VBA and get the substitution I
want?

Rick
Jul 17 '05 #1
2 2521
Azl
hi rick, i think i know what you are trying to do.

the error is because you don't have a field call "Array(I)" in your table.

anything after the "!" is the physical field name fro the table.

what you need to do instead is use the 'fields' collection from the
recordset. you line should read

if IsNull(rstTable.Fields(Array(I))) then

good luck

Al.

"Rick Caird" <cc****@CairdConsulting.com> wrote in message
news:3f********@news.snappydsl.net...
I am relatively new to VBA and have roots in TCL and 'C'. I was trying to
generalize a program by stuffing column names in an array and then using
array elements in a statement. For example:

Dim I As Integer
Dim Array(2) As String
Array(0) = "Contract Date"
Array(1) = "Paid Date"
Array(2) = "Some other date"

For I =0 To 2
If IsNull(rstTable!Array(I)) Then
Do Something
End If
Next I

Well, clearly it isn't working. I get a message saying that
rstTable!Array(I) is not a member of the group.

Is it possible to construct such a loop in VBA and get the substitution I
want?

Rick

Jul 17 '05 #2
Al,

Thanks. It is now working with your pointer.

Rick
"Azl" <A.B.Barker@_NoSpam_btinternet.com> wrote in message
news:bg**********@titan.btinternet.com...
hi rick, i think i know what you are trying to do.

the error is because you don't have a field call "Array(I)" in your table.

anything after the "!" is the physical field name fro the table.

what you need to do instead is use the 'fields' collection from the
recordset. you line should read

if IsNull(rstTable.Fields(Array(I))) then

good luck

Al.

"Rick Caird" <cc****@CairdConsulting.com> wrote in message
news:3f********@news.snappydsl.net...
I am relatively new to VBA and have roots in TCL and 'C'. I was trying to generalize a program by stuffing column names in an array and then using
array elements in a statement. For example:

Dim I As Integer
Dim Array(2) As String
Array(0) = "Contract Date"
Array(1) = "Paid Date"
Array(2) = "Some other date"

For I =0 To 2
If IsNull(rstTable!Array(I)) Then
Do Something
End If
Next I

Well, clearly it isn't working. I get a message saying that
rstTable!Array(I) is not a member of the group.

Is it possible to construct such a loop in VBA and get the substitution I want?

Rick


Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Jack | last post by:
Hi, I am trying to test a sql statement in Access which gives me the error as stated in the heading. The sql statement is built as a part of asp login verification, where the userid and password...
0
by: Reed | last post by:
Can someone stear me in the right direction to convert a binary tree from a Linked List to a Dynamic Array... Dynamic arrays aren't something im strong with. //********bintree.h******** #ifndef...
1
by: Chris | last post by:
I'm looking to create a dynamic jump menu/list menu that will enable me to navigate to a particular record by selecting a value from the list, however the list is dynamically generated from the...
1
by: Maziar Aflatoun | last post by:
Hi everyone, I have the following HTML code and I like to change the value of REFRESH content from 2 to something else at runtime. Any suggestions? <HTML> <HEAD> <meta name="GENERATOR"...
0
by: Pascal Costanza | last post by:
Dynamic Languages Day @ Vrije Universiteit Brussel ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Monday, February 13, 2006, VUB Campus Etterbeek The VUB (Programming Technology Lab,...
5
by: Sakcee | last post by:
python provides a great way of dynamically creating fuctions calls and class names from string a function/class name can be stored as string and called/initilzed e.g def foo(a,b): return...
5
by: newb guy | last post by:
Hi, I am interested in knowing how to dynamically modify what browser shows using javascript. I have seen advert programs that put a javascript at the end of html code, and then dynamically...
0
by: Cuperman | last post by:
Hi all, Is it possible to set dynamic web references in VS.NET 2005? Right clicking anywhere from the Web_References folder and below in my solution tree does not offer any "properties"...
2
by: Unpopular | last post by:
void directory::modification()//??????????? { clrscr(); cout<< "\n\t @@@@@@ @@@@@ @@@@@ @@@@@@ @@@@@ @ @ @@@@@@ "; cout<< "\n\t=====@ @ @ @ @ @ @@...
26
by: Aaron \Castironpi\ Brady | last post by:
Hello all, To me, this is a somewhat unintuitive behavior. I want to discuss the parts of it I don't understand. .... f= lambda: n .... 9 9
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.