(Q) Is it possible to have some fields filled in automatically as
soon as a certain value has been entered into another field?
(A) A typical example of this is getting state and city name from
Zipcodes. If you have a Zip-Code table, you'll never have to enter the State/City again.
Add this simple code in the OnExit() event-handler for the field containing the Zipcode.
Sub Zip_OnExit(Cancel As Integer)
Dim varState, varCity As Variant
varState = DLookup("State", "tblZipCode", "ZipCode =[Zip] ")
varCity = DLookup("City", "tblZipCode", "ZipCode =[Zip] ")
If (Not IsNull(varState)) Then Me![State] = varState
If (Not IsNull(varCity)) Then Me![City] = varCity
End Sub
|