query help

A

aspickwick

I am trying to write a query to categorize or bucket a memo field. I would
like to query the memo field and create 2 fields, one action and one noun
where the results would give me for the following memo field:
"replace drain valve, adjust door guide screw"
The following results
Action - replace; Noun - drain valve and
Action - adjust; Noun - door guide screw

And not:
Action - replace; Noun - Door guide screw
Action - adjust; Noun - drain valve
 
S

S.Clark

If you dictate a rule that the first word is always the verb, and subsequent
words are considered the noun, and actions are seperated by the period(or end
of text), then this may be feasible and simple.

Extracting the first word is easy. Use the InStr() function to find the
first space.

intPosSpace = InStr([fieldname], " ")
If intPosSpace > 0 then
strVerb = Left$([Fieldname], intPos - 1)
End If
intPosPeriod = InStr([Fieldname], ".")
If intPosPeriod > 0 then
strNoun = Mid$([Fieldname], intPosSpace+1, intPosPeriod -1)
else
strNoun = Mid$([Fieldname], intPosSpace+1)
end if

If you have multiple periods, then you'll need to loop until no more periods.
 
A

aspickwick

Thank you for your help! I will try it out.

S.Clark said:
If you dictate a rule that the first word is always the verb, and subsequent
words are considered the noun, and actions are seperated by the period(or end
of text), then this may be feasible and simple.

Extracting the first word is easy. Use the InStr() function to find the
first space.

intPosSpace = InStr([fieldname], " ")
If intPosSpace > 0 then
strVerb = Left$([Fieldname], intPos - 1)
End If
intPosPeriod = InStr([Fieldname], ".")
If intPosPeriod > 0 then
strNoun = Mid$([Fieldname], intPosSpace+1, intPosPeriod -1)
else
strNoun = Mid$([Fieldname], intPosSpace+1)
end if

If you have multiple periods, then you'll need to loop until no more periods.

--
Steve Clark,
Former Access MVP
FMS, Inc
http://www.fmsinc.com/consulting



aspickwick said:
I am trying to write a query to categorize or bucket a memo field. I would
like to query the memo field and create 2 fields, one action and one noun
where the results would give me for the following memo field:
"replace drain valve, adjust door guide screw"
The following results
Action - replace; Noun - drain valve and
Action - adjust; Noun - door guide screw

And not:
Action - replace; Noun - Door guide screw
Action - adjust; Noun - drain valve
 

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