View Full Version : Form with field box to enter S.S. #, is it possible to look up S.S. # to see if it


joe789
10-19-2001, 04:49 AM
Hi,

This is very interesting, at least I think so. I have created a form which is used to input data into a SQL Database. One of the many fields is for Social Security Number. All Social Security Numbers are unique except for one, 555-55-5555 which indicates someone who does not know their SS #. Before anyone can enter a new record into our database, they have to make sure that the given SS# of that record does not already exist in the system. Currently, to do the SSN search, the user simply enters the SS# in a search field and presses enter to run the search macro, if the SS# exists, the form will be populated with that SS# information - otherwise, Access will state that the SS# does not exist.

I would like to know if it is possible to do the following: to speed up data entry, I would like the user to enter the SS# in the SS# field on the form. Once the user enters the entire SS#, and that number does not exist (or that number is 555-55-5555); the user may enter the rest of the data in the other fields and progress as normal (which means using the enter key to progress thru the fields in the form). However, if the user enters a number other than 555-55-5555 that is already in the database, the form will automatically be populated with that Social Security Number's information until the user presses the add new record macro button.

I would greatly appreciate any help or assistance.

Thank you very much,

Joe

DJN
10-19-2001, 06:00 AM
I would open up a second form that is a duplicate of the data entry form. The secon dorm will have the same record source as the first. Then apply a filter in the before update event for your SS# field. Something like this.
If (Not IsNull(DLookup("[SS#]", "TableName", "[SS#] ='" & Me!txtBoxName& "'"))) Then
MsgBox "The SS# you have entered is a duplicate."
Cancel = True
txtTextBoxName.Undo
DoCmd.OpenForm "TableName", acNormal, , "[SS#]=forms![FormName]![TextBoxName]"
You will of course have to test for SS# 555-5555