=?Utf-8?B?YmlsbHM=?= said:
Not using a list box or combo box, what is the most fundamental / simple way
to validate that an entry into a transaction table ( eg. an orders table that
calls for partnumber to be input ) is for an existing / valid entry in a
'master table' ( eg. an existing partnumber in a partsmaster table ).
Firstly, you have to do this through a form - tables in Access do not support
this sort of validation. You can then use something like the DLookup function
to check if a matching record exists:
If IsNull(DLookup("PK","tblMaster","Entry=' " & Me!txtEntry & " ' ")) Then
' Order doesn't exist
Else
' Order does exist
End If
This is checking if there is a value for PK (which is the Primary Key field, so
must always exist for each record) in the main table (tblMaster) for a record
in the Entry field that has a value equal to Me!txtEntry (the control on the
form that you entered the data into). In the above example, I am assuming that
txtEntry is a string, hence the use of single quotes - if it is numeric, then
you do not need these quotes.