dfitz92
12-12-2000, 07:49 AM
My question is if i open a form and enter a persons SS#, how can I make the form automatically find and enter the persons name that matches the previously typed SS#?
|
View Full Version : Forms and automatic filling fields dfitz92 12-12-2000, 07:49 AM My question is if i open a form and enter a persons SS#, how can I make the form automatically find and enter the persons name that matches the previously typed SS#? Talismanic 12-12-2000, 08:05 AM Look in the help for DLookup. That will do what you want. If you need help with the syntax we will need more information like table. field names etc... Chris RR 12-12-2000, 08:10 AM You need to do two things. First you need to set up a text box for the employee name. In the Control Source for this field, you need to look up the employee name, something like this: =DLookUp("[EMP_NAME]","[EMP_NAMES_TABLE]","[SSN] = [SSN_Field]") Then, you'll need to write a little (a very little) VBA code for the "On Exit" property of the SSN field: Private Sub SSN_Field(Cancel As Integer) Me.Recalc End Sub The "recalc" makes the Dlookup happen. You may want to protect the name field (set Enabled to No, Locked to Yes) if you don't want the user to mess with it once you've found it. You may also want to put the Dlookup inside an "Iif". Use the Iif to make sure you've found a name, otherwise give the user a msg box. |