M
MimiSD
I am currently trying to create a form that will automatically fill in some
information once an ID has been entered. The info i want prefilled is all
stored in the same table as the ID number. I get it to work somewhat. When
I enter the ID number currently it will automatically fill in the information
from the first record and then duplicates the record. I am currently using
the code below to have the info prefilled. What am I doing wrong? I do not
want info duplicated and i want it to pull the correct corresponding records.
Sub SchoolCode_Exit(Cancel As Integer)
Dim varName, varAE, varFAO As Variant
varName = DLookup("SchoolName", "tblSchool", "SchoolCode =[SchoolCode] ")
varAE = DLookup("AEName", "tblSchool", "SchoolCode =[SchoolCode] ")
varFAO = DLookup("FAOName", "tblSchool", "SchoolCode =[SchoolCode] ")
If (Not IsNull(varName)) Then Me![SchoolName] = varName
If (Not IsNull(varAE)) Then Me![AEName] = varAE
If (Not IsNull(varFAO)) Then Me![FAOName] = varFAO
End Sub
information once an ID has been entered. The info i want prefilled is all
stored in the same table as the ID number. I get it to work somewhat. When
I enter the ID number currently it will automatically fill in the information
from the first record and then duplicates the record. I am currently using
the code below to have the info prefilled. What am I doing wrong? I do not
want info duplicated and i want it to pull the correct corresponding records.
Sub SchoolCode_Exit(Cancel As Integer)
Dim varName, varAE, varFAO As Variant
varName = DLookup("SchoolName", "tblSchool", "SchoolCode =[SchoolCode] ")
varAE = DLookup("AEName", "tblSchool", "SchoolCode =[SchoolCode] ")
varFAO = DLookup("FAOName", "tblSchool", "SchoolCode =[SchoolCode] ")
If (Not IsNull(varName)) Then Me![SchoolName] = varName
If (Not IsNull(varAE)) Then Me![AEName] = varAE
If (Not IsNull(varFAO)) Then Me![FAOName] = varFAO
End Sub