Query Text in the Mid of a memo

A

AngieSD

I am trying to query off a memo field [Description] the text that follows
"User Name: " until the first space the "User Name: " is not in the same
position nor is the text of the user name a fixed size.

I am working with an InStr function but I don't know how to stop at the " "
after the name.

Thanks so much for any help.
 
M

Marshall Barton

AngieSD said:
I am trying to query off a memo field [Description] the text that follows
"User Name: " until the first space the "User Name: " is not in the same
position nor is the text of the user name a fixed size.

I am working with an InStr function but I don't know how to stop at the " "
after the name.


Assuming you have a form with a text box where you can enter
the text you eant to search for, try using criteria
something like this:

Like "*User Name: " & Forms!theform.textbox & "*"
 
A

AngieSD

I am sorry it is an imported field from a csv file all I want returned in my
query from this field is the name after user name.

Marshall Barton said:
AngieSD said:
I am trying to query off a memo field [Description] the text that follows
"User Name: " until the first space the "User Name: " is not in the same
position nor is the text of the user name a fixed size.

I am working with an InStr function but I don't know how to stop at the " "
after the name.


Assuming you have a form with a text box where you can enter
the text you eant to search for, try using criteria
something like this:

Like "*User Name: " & Forms!theform.textbox & "*"
 
A

AngieSD

I am afraid my description is confusing..

The field I am pulling from has sample data:

blahblahblah User Name: anyname blahblahblah
blahblah User Name: diffname blah
blahblahblahblahblah User Name: lastname blahblahblahblah

I want my query to return:

anyname
diffname
lastname

I hope that makes more sense.

Thank you again for the help!

Angie

Marshall Barton said:
AngieSD said:
I am trying to query off a memo field [Description] the text that follows
"User Name: " until the first space the "User Name: " is not in the same
position nor is the text of the user name a fixed size.

I am working with an InStr function but I don't know how to stop at the " "
after the name.


Assuming you have a form with a text box where you can enter
the text you eant to search for, try using criteria
something like this:

Like "*User Name: " & Forms!theform.textbox & "*"
 
J

John W. Vinson

I am afraid my description is confusing..

The field I am pulling from has sample data:

blahblahblah User Name: anyname blahblahblah
blahblah User Name: diffname blah
blahblahblahblahblah User Name: lastname blahblahblahblah

I want my query to return:

anyname
diffname
lastname

You'll have to play around with Mid() and InStr() functions.

Try:

Username: MID([memofield], Instr([memofield], " User Name:") + 12,
InStr(Instr([memofield], " User Name:") + 12, [memofield], " ") -
(Instr([memofield], " User Name:") +12))

John W. Vinson [MVP]
 
A

AngieSD

That did it!! I was on that same track but you saved me a lot of trial and
error!!! Thank you

John W. Vinson said:
I am afraid my description is confusing..

The field I am pulling from has sample data:

blahblahblah User Name: anyname blahblahblah
blahblah User Name: diffname blah
blahblahblahblahblah User Name: lastname blahblahblahblah

I want my query to return:

anyname
diffname
lastname

You'll have to play around with Mid() and InStr() functions.

Try:

Username: MID([memofield], Instr([memofield], " User Name:") + 12,
InStr(Instr([memofield], " User Name:") + 12, [memofield], " ") -
(Instr([memofield], " User Name:") +12))

John W. Vinson [MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top