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

trying to use a variable as a part of a string....why is this


tempname = FindSpaces(rs![column 1])
this works fine but if I try to pass a variable value to it

For i = 1 To 3 Step 2
tempname = FindSpaces(rs![column (i)])

why can't the variable i just be used in this way?
Is it because of the space in the name column 1 or is
it something else?

thanks for any pointers

Jerry

Apr 5 '06 #1
3 1177
Hi Jerry

try instead

dim strName as string

For i = 1 To 3 Step 2
strname = "Column " & trim(str(i))
tempname = FindSpaces(rs.fields(strname))
next

-Dick Christoph
"sparks" <js******@swbell.net> wrote in message
news:ua********************************@4ax.com...

tempname = FindSpaces(rs![column 1])
this works fine but if I try to pass a variable value to it

For i = 1 To 3 Step 2
tempname = FindSpaces(rs![column (i)])

why can't the variable i just be used in this way?
Is it because of the space in the name column 1 or is
it something else?

thanks for any pointers

Jerry

Apr 5 '06 #2
that did it thanks a lot.
but why do you have to rebuild the string, is it because of the space
in the name?

Jerry
On Wed, 05 Apr 2006 15:34:10 GMT, "DickChristoph"
<dc********@yahoo.com> wrote:
Hi Jerry

try instead

dim strName as string

For i = 1 To 3 Step 2
strname = "Column " & trim(str(i))
tempname = FindSpaces(rs.fields(strname))
next

-Dick Christoph
"sparks" <js******@swbell.net> wrote in message
news:ua********************************@4ax.com.. .

tempname = FindSpaces(rs![column 1])
this works fine but if I try to pass a variable value to it

For i = 1 To 3 Step 2
tempname = FindSpaces(rs![column (i)])

why can't the variable i just be used in this way?
Is it because of the space in the name column 1 or is
it something else?

thanks for any pointers

Jerry


Apr 5 '06 #3
Hi Jerry

No It is because the syntax of VBA doesn't allow a variable in this context.

Given this it would expect the field name is "column (i)" which not only
isn't what you want but has nothing to do with the value of i.
tempname = FindSpaces(rs![column (i)])

-Dick Christoph
"sparks" <js******@swbell.net> wrote in message
news:ov********************************@4ax.com... that did it thanks a lot.
but why do you have to rebuild the string, is it because of the space
in the name?

Jerry
On Wed, 05 Apr 2006 15:34:10 GMT, "DickChristoph"
<dc********@yahoo.com> wrote:
Hi Jerry

try instead

dim strName as string

For i = 1 To 3 Step 2
strname = "Column " & trim(str(i))
tempname = FindSpaces(rs.fields(strname))
next

-Dick Christoph
"sparks" <js******@swbell.net> wrote in message
news:ua********************************@4ax.com. ..

tempname = FindSpaces(rs![column 1])
this works fine but if I try to pass a variable value to it

For i = 1 To 3 Step 2
tempname = FindSpaces(rs![column (i)])

why can't the variable i just be used in this way?
Is it because of the space in the name column 1 or is
it something else?

thanks for any pointers

Jerry

Apr 5 '06 #4

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

Similar topics

6
by: Paul C-T | last post by:
I've read the newsgroups on this ... the PHP website and I'm still confused .... I am parsing a variable $howmany to a for / loop to print out multiple form fields with similar names ... for ($t...
8
by: Rich Grise | last post by:
I think I've finally found a tutorial that can get me started: http://www.zib.de/Visual/people/mueller/Course/Tutorial/tutorial.html and I've been lurking for awhile as well. What happened is,...
4
by: Augustus S.F.X Van Dusen | last post by:
I have recently come across the following construction: #define P_VAR(output, string, args...) \ fprintf (output, "This is "string"\n", ##args) which can be invoked as follows: int x = 1,...
2
by: | last post by:
I have gotten the following error in trying to get totals to come out on a footer. Server Error in '/test' Application....
4
by: Friday | last post by:
Being an Old L.A.M.P guy, I beg you to please excuse my ignorance of dot.net (and all things Windows, for that matter). As part of an experiment (to learn enough ASP/VB.net to port a series of ...
7
by: Aaron | last post by:
Complete code follows. I am new to .NET programming (and programming in general) and I am having a difficult time understanding how to fill a variable in one sub, and then access it from...
23
by: Russ Chinoy | last post by:
Hi, This may be a totally newbie question, but I'm stumped. If I have a function such as: function DoSomething(strVarName) { ..... }
2
by: simon | last post by:
hello, what i'm looking to do is store the path of the app on a the server for reuse in the site. my thoughts so far are... -make a key in the web.config file -retrieve the value in globals.asax...
17
by: Control Freq | last post by:
Hi, Not sure if this is the right NG for this, but, is there a convention for the variable names of a Session variable? I am using .NET 2.0 in C#. I am new to all this .NET stuff, So, any...
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: 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
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.