PC Review


Reply
Thread Tools Rate Thread

![column] AS variable

 
 
Tim
Guest
Posts: n/a
 
      18th Sep 2003
I can't figure out how to use a variable in place of a
![column] statement in a With statement. In the following
code, I would like to replace [m1] with a variable so that
I can use the same code on different columns by changing
the variable rather than reusing the entire code. If I
try using a string variable in place of [m1] it doesn't
work. Do I need to declare a different type of variable?
Here is the code that I'm trying to use:

Do While myCount <> 0
With MyTbl
If ![Type] = dType Then
If ![m1] = colVal Then
mrank = mrank
Else
mrank = mrank + 1
End If
Else
If ![Type] <> dType Then
mrank = 1
dType = ![Type]
End If
End If
colVal = ![m1]
..Edit
![m1Rank] = mrank
..Update
..MoveNext
End With

myCount = myCount - 1

Loop
 
Reply With Quote
 
 
 
 
Allen Browne
Guest
Posts: n/a
 
      18th Sep 2003
May need to avoid the With block, but you can use:
MyTbl("MyField")
so
strFieldName = "MyField")
MyTable(strFieldName)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"Tim" <(E-Mail Removed)> wrote in message
news:00ab01c37df3$22795dd0$(E-Mail Removed)...
> I can't figure out how to use a variable in place of a
> ![column] statement in a With statement. In the following
> code, I would like to replace [m1] with a variable so that
> I can use the same code on different columns by changing
> the variable rather than reusing the entire code. If I
> try using a string variable in place of [m1] it doesn't
> work. Do I need to declare a different type of variable?
> Here is the code that I'm trying to use:
>
> Do While myCount <> 0
> With MyTbl
> If ![Type] = dType Then
> If ![m1] = colVal Then
> mrank = mrank
> Else
> mrank = mrank + 1
> End If
> Else
> If ![Type] <> dType Then
> mrank = 1
> dType = ![Type]
> End If
> End If
> colVal = ![m1]
> .Edit
> ![m1Rank] = mrank
> .Update
> .MoveNext
> End With
>
> myCount = myCount - 1
>
> Loop



 
Reply With Quote
 
thad
Guest
Posts: n/a
 
      18th Sep 2003
I didn't know you could do it that. I learn something
every day. I typically use

rs.Fields(strFieldName)

>-----Original Message-----
>May need to avoid the With block, but you can use:
> MyTbl("MyField")
>so
> strFieldName = "MyField")
> MyTable(strFieldName)
>
>--
>Allen Browne - Microsoft MVP. Perth, Western Australia.
>Tips for Access users - http://allenbrowne.com/tips.html
>
>"Tim" <(E-Mail Removed)> wrote in message
>news:00ab01c37df3$22795dd0$(E-Mail Removed)...
>> I can't figure out how to use a variable in place of a
>> ![column] statement in a With statement. In the

following
>> code, I would like to replace [m1] with a variable so

that
>> I can use the same code on different columns by changing
>> the variable rather than reusing the entire code. If I
>> try using a string variable in place of [m1] it doesn't
>> work. Do I need to declare a different type of

variable?
>> Here is the code that I'm trying to use:
>>
>> Do While myCount <> 0
>> With MyTbl
>> If ![Type] = dType Then
>> If ![m1] = colVal Then
>> mrank = mrank
>> Else
>> mrank = mrank + 1
>> End If
>> Else
>> If ![Type] <> dType Then
>> mrank = 1
>> dType = ![Type]
>> End If
>> End If
>> colVal = ![m1]
>> .Edit
>> ![m1Rank] = mrank
>> .Update
>> .MoveNext
>> End With
>>
>> myCount = myCount - 1
>>
>> Loop

>
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I pull variable URL from one column and download the contentto another column? pand0ra.usa Microsoft Excel Programming 3 26th Aug 2009 11:38 PM
variable column Libby Microsoft Excel Worksheet Functions 1 28th Jan 2008 06:32 PM
copy a range with known start column to variable end column =?Utf-8?B?TWF0aWxkYQ==?= Microsoft Excel Programming 2 2nd Aug 2006 04:55 PM
Offset from a variable column to a fixed column =?Utf-8?B?S3VydCBCYXJy?= Microsoft Excel Programming 2 27th Jun 2006 05:45 PM
Sum cells based on a row variable and seperate column variable =?Utf-8?B?Q2hlZXNlSGVhZFRyYW5zcGxhbnQ=?= Microsoft Excel Worksheet Functions 10 23rd Sep 2005 06:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:45 AM.