Help with If Then...

  • Thread starter David Ehrenreich
  • Start date
D

David Ehrenreich

Hello,

I need help finishing after the then in this code.

Private Sub Fname_GotFocus()

If Not IsNull(DLookup("ssn", "cardInfoTbl", _
"ssn='" & Me.ssn & "'")) Then
me.fname = me.fname !This what I need help with


End If
End Sub

Ok this is how this works. When a ssn# is entered it is
supposed to enter the name if that social has been used
before. The part before the then works fine I checked it
by putting a message box after the then and when a social
was used more then once it would appear. It's just I cant
figure out how to have the name entered from that social.

I hope this makes sense it does to me :)

David Ehrenreich
 
K

Kelvin

You need to keep using the DLookup command.

If Not IsNull(Dlookup("ssn",cardInfoTbl","ssn='" & Me.ssn &"'")) Then
Me.fName = Dlookup("fname",cardInfoTbl","ssn='" & Me.ssn & "'"))
End If

I would move this out of the got focus event and into the before update
event. The got focus event will be triggered before you finish entering the
ssn. The before update event can be used to clear the ssn and allow the
user to enter a new number.

Kelvin
 

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

Similar Threads


Top