find and display specific piece of text in a memo field

J

J Kai

I had to pull data from another system and place into access. one of the
fields is a memo field that contains a file number. The format of the file
number is ##-###.

Is there a way to find the text using wildcards *#-##* in a query and only
have the file number display in the result.
 
J

Jerry Whittle

Something like below, with the proper table and field names, will look for
the first - in the memo field and return the characters around it. If there
are any other dashes, such as in a phone number like 555-555-5555, all bets
are off.

SELECT Mid([MEMOFIELD], InStr([MEMOFIELD], "-")-2,6) AS TheFileNumber
FROM YourTable
WHERE InStr([MEMOFIELD],"-")>1;
 
J

J Kai

Jerry,

It was perfect. I kept thinking of finding the whole file number. Searching
for the dash was great.

J Kai

Jerry Whittle said:
Something like below, with the proper table and field names, will look for
the first - in the memo field and return the characters around it. If there
are any other dashes, such as in a phone number like 555-555-5555, all bets
are off.

SELECT Mid([MEMOFIELD], InStr([MEMOFIELD], "-")-2,6) AS TheFileNumber
FROM YourTable
WHERE InStr([MEMOFIELD],"-")>1;
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

J Kai said:
I had to pull data from another system and place into access. one of the
fields is a memo field that contains a file number. The format of the file
number is ##-###.

Is there a way to find the text using wildcards *#-##* in a query and only
have the file number display in the result.
 

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