Check for values in form field to a table

Christine Pearc

Christine
Local time
Today, 10:52
Joined
May 13, 2004
Messages
111
I'm certain this question has probably been asked before, but I can't seem to find it!

I have a form field called fldTitle, and want to ensure users write something that is meaningful by evaluating words within the title to a table of keywords (tblKeywords). I know how to write the IF/ENDIF and the other stuff required, but am struggling to find the right commands to do the comparision. Could someone help me out?

Many thanks.
 
Hi -

Not quite sure what aspect of this is generating your question. My basic approach would be to write a loop to read each of the key words and check to see if the keywords are in the title.

You can use the InStr function to check for the presence of one string within another (Quote from the help file):

Dim SearchString, SearchChar, MyPos
SearchString ="XXpXXpXXPXXP" ' String to search in.
SearchChar = "P" ' Search for "P".

' A textual comparison starting at position 4. Returns 6.
MyPos = Instr(4, SearchString, SearchChar, 1)

' A binary comparison starting at position 1. Returns 9.
MyPos = Instr(1, SearchString, SearchChar, 0)

' Comparison is binary by default (last argument is omitted).
MyPos = Instr(SearchString, SearchChar) ' Returns 9.

MyPos = Instr(1, SearchString, "W") ' Returns 0.

Post back if that is not what you are looking for.

-g
 
Thanks, Gromit - that's what I was looking for!
 
Is it possible to restrict user input to selecting a word from your list? A simple combo box would ensure that only the words you provide can be selected, and that they are correctly spelled!
 
I wish it could be so easy, Neil! What I'm trying to do is to check that operators are writing a title for a Corrective Action Request that actually says something meaningful! Dispite best efforts with training, on-line help, etc. we're seeing statements like "The widget doesn't work", "Document wrong", etc. I'm hoping to check for a few key words that, if missing from the title, will make the operator think about what they are writing. I'm not sure if it will work, but want to give it a go!
 
Neil has a good point - if you can set up a combo box with the most commonly used titles, then you can offer the user a painless way to select something meaningful.

You can trap the Not in List event and do additional work to try to validate the title.

-g
 
Hi Gromit. The CAR system is used to track deficiencies throughout the company - from engineering to reception - so standard "error codes" or descriptions like one might use in, say, a manufacturing or test environment, wouldn't work. Cheers for your input anyway.
 

Users who are viewing this thread

Back
Top Bottom