From: alex on
Check List in VBA

Hello,

I’m looking for advice on the following:

Let’s say you wanted to check a list of values (same data type, same
length, etc) without using a table in VBA.

Something like…
If strValue in (
Value1,
Value2,
Value3,
ValueN)
Then do something

With a short list, a simple case statement would suffice, but because
of its structure (TestExpression), (ExpressionList), (StatementBlock),
it could get rather long.

What I’m trying to do is verify a list of user ID’s in code without
using a table object (which would be linked).

Am I crazy or can/should this be done easily? My reasoning is that
it’s faster and while not super secure, more secure than a table.

Thanks,
alex
From: Tom Wickerath AOS168b AT comcast DOT on
Hi Alex,

You can use the InStr function. Something like this:

strValues = "User1, User2, User3, User4, ....."

If InStr (strValues, strSearch) > 0 Then 'we found a match
Do something
End If

where strSearch is the value you are looking for.


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
__________________________________________


"alex" wrote:

> Check List in VBA
>
> Hello,
>
> I'm looking for advice on the following:
>
> Let's say you wanted to check a list of values (same data type, same
> length, etc) without using a table in VBA.
>
> Something like…
> If strValue in (
> Value1,
> Value2,
> Value3,
> ValueN)
> Then do something
>
> With a short list, a simple case statement would suffice, but because
> of its structure (TestExpression), (ExpressionList), (StatementBlock),
> it could get rather long.
>
> What I'm trying to do is verify a list of user ID's in code without
> using a table object (which would be linked).
>
> Am I crazy or can/should this be done easily? My reasoning is that
> it's faster and while not super secure, more secure than a table.
>
> Thanks,
> alex
> .
>
From: alex on
On Jan 21, 4:31 pm, Tom Wickerath <AOS168b AT comcast DOT net> wrote:
> Hi Alex,
>
> You can use the InStr function. Something like this:
>
> strValues = "User1, User2, User3, User4, ....."
>
> If InStr (strValues, strSearch) > 0 Then 'we found a match
>     Do something
> End If
>
> where strSearch is the value you are looking for.
>
> Tom Wickerath
> Microsoft Access MVPhttp://www.accessmvp.com/TWickerath/
> __________________________________________
>
>
>
> "alex" wrote:
> > Check List in VBA
>
> > Hello,
>
> > I’m looking for advice on the following:
>
> > Let’s say you wanted to check a list of values (same data type, same
> > length, etc) without using a table in VBA.
>
> > Something like…
> > If strValue in (
> > Value1,
> > Value2,
> > Value3,
> > ValueN)
> > Then do something
>
> > With a short list, a simple case statement would suffice, but because
> > of its structure (TestExpression), (ExpressionList), (StatementBlock),
> > it could get rather long.
>
> > What I’m trying to do is verify a list of user ID’s in code without
> > using a table object (which would be linked).
>
> > Am I crazy or can/should this be done easily?  My reasoning is that
> > it’s faster and while not super secure, more secure than a table.
>
> > Thanks,
> > alex
> > .- Hide quoted text -
>
> - Show quoted text -

Thanks Tom for the help; I never thought of using that function!
I was hoping to go vertical with the list (might be easier to
maintain) but VBA only allows a certain number of continuation
characters ( _ ).
alex
From: Tom Wickerath AOS168b AT comcast DOT on
Hi Alex,

I've never heard of any limit for the number of line continuation
characters....what limit have you determined?

The best place for data is to store it in a table. You could then open a
recordset, and look for a match. But, you indicated in your opening post that
you are trying to accomplish this goal without using a table.


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
__________________________________________

"alex" wrote:
>
> Thanks Tom for the help; I never thought of using that function!
> I was hoping to go vertical with the list (might be easier to
> maintain) but VBA only allows a certain number of continuation
> characters ( _ ).
> alex
From: John Spencer on
In Access 2003 I was allowed 24 before I got an error message about too many
line continuations. There is also a line length restriction - which I don't
recall at this time.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Tom Wickerath wrote:
> Hi Alex,
>
> I've never heard of any limit for the number of line continuation
> characters....what limit have you determined?
>
> The best place for data is to store it in a table. You could then open a
> recordset, and look for a match. But, you indicated in your opening post that
> you are trying to accomplish this goal without using a table.
>
>
> Tom Wickerath
> Microsoft Access MVP
> http://www.accessmvp.com/TWickerath/
> __________________________________________
>
> "alex" wrote:
>> Thanks Tom for the help; I never thought of using that function!
>> I was hoping to go vertical with the list (might be easier to
>> maintain) but VBA only allows a certain number of continuation
>> characters ( _ ).
>> alex
 |  Next  |  Last
Pages: 1 2
Prev: vertragen
Next: access 2007 add contacts from outlook