Topic: Entry exists in another table

Hi folks,

I have two tables which are linked. When I make an entry into the ID field in one table, how can I check that the details I have entered exist in a field in another table?

(What I´m trying to do is make sure that when I enter the part number of an item which has been delivered in my "orders" table, that the part number actually exists in my "parts" table)

Thanks

2 (edited by derek 2017-09-10 20:35:15)

Re: Entry exists in another table

Hi Knobby,
If the two tables are linked, the easiest way is to check it against a combobox;  in your example, if it's not in your "parts" table, then it won't be displayed in the combobox.
However, if there are a large number of entries in the combobox, it can be a bit time consuming scrolling up and down for the correct entry.  In this case, there are a couple of options that I could think of.
Option 1 (no script)
With the cursor in the combobox, start typing the part no' and the combobox will highlight all those values that match what you have typed.  This seems the most straightforward way to me but it doesn't allow for wildcards (ie it is a 'left to right' match of what you have entered).
Option 2 (with script - but not much!)
Use an edit field to build a combobox on the fly, depending on what you type into that edit field.  In this example, I'm allowing for wildcard searches so what you type in can appear anywhere in the part no'.
In both options, the combobox is a concatenation of the part no' and the part description (for extra visual validation) but it doesn't affect the searching.
Please see the attached and hopefully it will give you some ideas.
Regards,
Derek.

Post's attachments

Attachment icon knobby parts check.zip 691.38 kb, 328 downloads since 2017-09-10