validation

B

bills

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 ).
 
J

JSand42737

=?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.
 
V

Van T. Dinh

Enforcing the Referntial Integrity between the PartsMaster
Table and the Transaction Table. The validation will be
done by the Database Engine which is more efficient than
code.

Check Access Help / Access Book on Referential Integrity.

HTH
Van T. Dinh
MVP (Access)


-----Original Message-----
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 ).
 
G

Guest

Jon,
I overlooked one of the most basic features - enforcing
referential integrity -> which does the validation job
quite well and simply at the table level ( see note to me
from Van T. Dinh ) thanks again.BillS
-----Original Message-----
 

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