Help w/ writing a If Statement

  • Thread starter Thread starter David Ehrenreich
  • Start date Start date
D

David Ehrenreich

Here is what I'm trying to do. In my form I have feilds
for Ssn# FName, Lname. Since the social and Fname and
last name are always connected. I would like it so that
when I type in a ssn# the Fname and Last name are
automatically entered into their feilds. Here is what I
have tried and it failed :).

Private Sub Ssn_LostFocus()

If Not IsNull(DLookup "ssn","CardInfoTbl", _
"ssn=")) Then
FName = Me.FName


End If
End Sub

Thank You
David Ehrenreich
 
Create a query based on CardInfoTbl and include these fields in this order:
SSN
FName
LName

On your form add a combobox with the rowsource the above query. Make the bound
column 1, column count 3 and column widths 1.5;0;0. You can now select the SSN
on your form!

Put this code in the AfterUpdate event of the combobox:

Me!FName = Me!NameOfCombobox.Column(1)
Me!LName = Me!NameOfCombobox.Column(2)

This code will automatically fill your first and last name fields on your form
when you select a SSN.
 
Hmm. I don't think that way will work with what I need to
do. See, I work in a testing center so we have lots of
traffic with students. The way you explained would work
if we had only a few students. Thank you for the help.
If I'm missing something let me know.

Thank you
David Ehrenreich
 
In the query for the combobox, sort SSN ascending. Then set the AutoExpand of
the combobox to Yes. You can now type in the first few digits of the SSN and the
combobox will automatically scroll to the first SSN beginning with the digits
you entered. From there you can easily find the student you want, select that
student and your underlying form will jump to that student's record.
 
Back
Top