Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto-populating form fields

Status
Not open for further replies.

kirnavi

Technical User
Feb 4, 2002
29
US
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.
 
Try Me![txtAddrState].Value petersdaniel@hotmail.com
"If A equals success, then the formula is: A=X+Y+Z. X is work. Y is play. Z is keep your mouth shut." --Albert Einstein

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top