Hi - I've got a form which is based on a linked table. I would like the users to enter a social security number and have the participant's name, address, etc automatically populate a number of fields. Here's what I have cobbled together so far:
Private Sub txtSSN_AfterUpdate()
Dim varName, varBirthdate, varAddr1, varAddr2, varAddr3, varAddr4, varAddr5, varState, varZip, As Variant
varName = DLookup("A Owner Mail Name", "PARTICIPANT", "txtSSN =[A PARTICIPANT ID] "
varBirthdate = DLookup("A Annt Birth Mo", "PARTICIPANT", "txtSSN =[A PARTICIPANT ID] "
varAddr1 = DLookup("A Owner Addr 1", "PARTICIPANT", "txtSSN =[A PARTICIPANT ID] "
varAddr2 = DLookup("A Owner Addr 2", "PARTICIPANT", "txtSSN =[A PARTICIPANT ID] "
varAddr3 = DLookup("A Owner Addr 3", "PARTICIPANT", "txtSSN =[A PARTICIPANT ID] "
varAddr4 = DLookup("A Owner Addr 4", "PARTICIPANT", "txtSSN =[A PARTICIPANT ID] "
varAddr5 = DLookup("A Owner Addr 5", "PARTICIPANT", "txtSSN =[A PARTICIPANT ID] "
varState = DLookup("A Owner State", "PARTICIPANT", "SSN =[A PARTICIPANT ID] "
varZip = DLookup("A Owner Zip", "PARTICIPANT", "SSN =[A PARTICIPANT ID] "
If (Not IsNull(varName)) Then Me![txtName] = varName
If (Not IsNull(varBirthdate)) Then Me![txtBirthdate] = varBirthdate
If (Not IsNull(varAddr1)) Then Me![txtAddr1] = varAddr1
If (Not IsNull(varAddr2)) Then Me![txtAddr2] = varAddr2
If (Not IsNull(varAddr3)) Then Me![txtAddr3] = varAddr3
If (Not IsNull(varAddr4)) Then Me![txtAddr4] = varAddr4
If (Not IsNull(varAddr5)) Then Me![txtAddr5] = varAddr5
If (Not IsNull(varState)) Then Me![txtAddrState] = varState
If (Not IsNull(varZip)) Then Me![txtAddrZip] = varZip
End Sub
When I test it, there are no errors (anymore) but nothing happens. I think I am missing something major. My fields that I want populated are called txtName, txtBirthdate, txtAddr1, txtAddr2, txtAddr3, txtAddr4, txtAddr5, txtAddrState, and txtAddrZip.
Can anyone help?
Thanks.
Private Sub txtSSN_AfterUpdate()
Dim varName, varBirthdate, varAddr1, varAddr2, varAddr3, varAddr4, varAddr5, varState, varZip, As Variant
varName = DLookup("A Owner Mail Name", "PARTICIPANT", "txtSSN =[A PARTICIPANT ID] "
varBirthdate = DLookup("A Annt Birth Mo", "PARTICIPANT", "txtSSN =[A PARTICIPANT ID] "
varAddr1 = DLookup("A Owner Addr 1", "PARTICIPANT", "txtSSN =[A PARTICIPANT ID] "
varAddr2 = DLookup("A Owner Addr 2", "PARTICIPANT", "txtSSN =[A PARTICIPANT ID] "
varAddr3 = DLookup("A Owner Addr 3", "PARTICIPANT", "txtSSN =[A PARTICIPANT ID] "
varAddr4 = DLookup("A Owner Addr 4", "PARTICIPANT", "txtSSN =[A PARTICIPANT ID] "
varAddr5 = DLookup("A Owner Addr 5", "PARTICIPANT", "txtSSN =[A PARTICIPANT ID] "
varState = DLookup("A Owner State", "PARTICIPANT", "SSN =[A PARTICIPANT ID] "
varZip = DLookup("A Owner Zip", "PARTICIPANT", "SSN =[A PARTICIPANT ID] "
If (Not IsNull(varName)) Then Me![txtName] = varName
If (Not IsNull(varBirthdate)) Then Me![txtBirthdate] = varBirthdate
If (Not IsNull(varAddr1)) Then Me![txtAddr1] = varAddr1
If (Not IsNull(varAddr2)) Then Me![txtAddr2] = varAddr2
If (Not IsNull(varAddr3)) Then Me![txtAddr3] = varAddr3
If (Not IsNull(varAddr4)) Then Me![txtAddr4] = varAddr4
If (Not IsNull(varAddr5)) Then Me![txtAddr5] = varAddr5
If (Not IsNull(varState)) Then Me![txtAddrState] = varState
If (Not IsNull(varZip)) Then Me![txtAddrZip] = varZip
End Sub
When I test it, there are no errors (anymore) but nothing happens. I think I am missing something major. My fields that I want populated are called txtName, txtBirthdate, txtAddr1, txtAddr2, txtAddr3, txtAddr4, txtAddr5, txtAddrState, and txtAddrZip.
Can anyone help?
Thanks.