Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Find field containing character
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Find field containing character

 Post Reply Post Reply
Author
pedalcars View Drop Down
Senior Member
Senior Member


Joined: 12 August 2002
Location: United Kingdom
Status: Offline
Points: 268
Post Options Post Options   Thanks (0) Thanks(0)   Quote pedalcars Quote  Post ReplyReply Direct Link To This Post Topic: Find field containing character
    Posted: 08 January 2004 at 10:36am


Is it possible to do something along the lines of the

Mid(stringToExamin, [start_position>, [number_of_characters>) = [Condition_character>

expression in a strSQL statement?

Currently I have along the lines of:

strSQL = "SELECT tblTable.* FROM tblTable;"

'Then having opened the connection and running through have:
If Mid(rs("permissions"), lngAccessLevel, 1) = 1 Then

'Display record

End If

'movenext, loop, etc.

Where tblTable.permissions is a text string (eg, 1101) and lngAccessLevel is the user's status (eg, 1, 2, 3 or 4).

So a level 3 user wont see that record, but others will.

Is it possible to apply the same conditions in the strSQL statement instead, to filter out records the user can't see, rather than bringing them back only to ignore them?

Something like (in concept):

strSQL = "SELECT tblTable.* FROM tblTable WHERE Mid(tblTable.permissions, lngAccessLevel, 1) = 1;"

(which doesn't work - doesn't bring back and errors but doesn't show any records either, even though it "should")

Ta

www.pedalcars.info

The most fun on four wheels

Back to Top
aalavar View Drop Down
Groupie
Groupie


Joined: 08 December 2003
Status: Offline
Points: 46
Post Options Post Options   Thanks (0) Thanks(0)   Quote aalavar Quote  Post ReplyReply Direct Link To This Post Posted: 08 January 2004 at 10:47am

Let's say your permissions are always 4 characters, let's also say you want to obtain records with the character '1' in the 2nd slot... ie it would retrieve 0100, but not 1011.  I think this will work:

select * from tbleTable where permissions like '_1__'

Back to Top
pedalcars View Drop Down
Senior Member
Senior Member


Joined: 12 August 2002
Location: United Kingdom
Status: Offline
Points: 268
Post Options Post Options   Thanks (0) Thanks(0)   Quote pedalcars Quote  Post ReplyReply Direct Link To This Post Posted: 08 January 2004 at 11:27am

Thanks - I went to try this and then found my version *does* work - when you specify the correct field in the strSQL expression and not an entirely different one!

D'oH!

I feel a bit  stoopid...

www.pedalcars.info

The most fun on four wheels

Back to Top
aalavar View Drop Down
Groupie
Groupie


Joined: 08 December 2003
Status: Offline
Points: 46
Post Options Post Options   Thanks (0) Thanks(0)   Quote aalavar Quote  Post ReplyReply Direct Link To This Post Posted: 08 January 2004 at 12:47pm

Well sure don't use my answers!

 

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.