PDA

View Full Version : Extracting part of a field of data from an MSAccess table


Brad
11-26-2002, 03:33 PM
Hi,

Hopefully this isn't too tricky, and somoene will be able to help me...

We have some data stored in an MSAccess table, and part of one of the fields has text within quotation marks. I need to be able to extract only the part of the text that is within the quotation marks, or better still, edit it.

the field is actually a freetext one which holds a user name and password, the password being the part in quotation marks, so:

username = joe bloggs Password="joepassword"

( don't need text out here but "textinhere" needs extracting )

So if I can take it, store it, change it, then resave it to the same place, that would be grand, then work down the whole table full of the same information for all our different users.

Thanks in advance,
Brad.

rcreyes
11-26-2002, 06:03 PM
This will extract the value between the ""
in this case the variable s will hold the value of the field,please note that this will only work in the format you specified in your post. i.e.

username = joe bloggs Password="joepassword"


Mid(s, Instr(s, Chr(34) ) + 1 , Len(s) - Instr(s, CHR(34) )-1 )

Brad
11-27-2002, 05:16 PM
Thanks very much, rcreyes,

I think I'm getting there with that, but is there any way of getting rid of the quotes around the characters that are shown, please ???

So instead of "joepassword" all you can see is joepassword ?

Brad.

whammy
11-28-2002, 01:12 PM
s = Replace(Mid(s, Instr(s, Chr(34) ) + 1 , Len(s) - Instr(s, CHR(34) )-1 ),"""","")

:D

But I'm at a total loss as to why you don't just have separate "user" and "pass" fields in the database table to contain this information... the above is definitely not a usual way to store usernames and passwords. :confused:

Brad
11-28-2002, 01:18 PM
Thanks Whammy i'll give it a go.

The whole table is an imported, or linked, file from an Ascend RADIUS password file, which just looks at certain bits of the file for its authentication - I'm trying to automate a regular password change.

Cheers,
Brad.