Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / April 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sparks - 05 Apr 2006 13:04 GMT
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
DickChristoph - 05 Apr 2006 16:34 GMT
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

> tempname = FindSpaces(rs![column 1])
> this works fine but if I try to pass a variable value to it
[quoted text clipped - 9 lines]
>
> Jerry
sparks - 05 Apr 2006 16:54 GMT
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

>Hi Jerry
>
[quoted text clipped - 22 lines]
>>
>> Jerry
DickChristoph - 05 Apr 2006 20:13 GMT
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
> that did it thanks a lot.
> but why do you have to rebuild the string, is it because of the space
[quoted text clipped - 28 lines]
>>>
>>> Jerry
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.