Data entry validation

  • Thread starter Thread starter Van123
  • Start date Start date
V

Van123

Hi

I have created a form in Access, in which data must be entered in the
unique id field in order to retrieve the rest of the data required on
the form.. I have created a query which checks if the unique id is in
a particular table, and if it is, the relative info is populated.

However, I wish to now add some error handling, and would like to be
able to output a message onto the screen if the unique id entered is
NOT in the table. I seem to be a having a few problems with the
syntax of this.

Thanks
 
Hi,

MOst probably you are using a textbox. Basically I can propose 2 solutions :
1) with textbox
you create an afterupdate event procedure and there you add code like to
verify whether is exists in the recordset (query) this is just an example an
dlookup is not the best there is but it's easy.

dim id as long
id =nz(dlookup("ID","YourTable","ID=" & txtNumber),0)
if id =0 then
msgbox "this number is not valid"
txtNUmber=""
else
' get your record information
end if

2) You could use a dropdown which is populated with only the possible ids
so ddID.rowsource = "SELECT ID FROM MyTable"

I hope this helps.

- Raoul
 
Back
Top