K
Kim
Some MVP designed this code
can I use it differently and how?
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(varState))Then Me![City] = varCity
End Sub
Here is my information:
I have a query turned into a form and a table.
Form name Copy of qry:CANTEST
boxes on form:
NEW CAN#
FY
Transaction Amount
My table name tbl:CANFY2003
Fields:
CAN
RESEARCH
DIVISION
POOL
Notes
I understand that there are other ways to accomplish this
but I want to use code and I'm trying to figure out if I
need to design a box on a form or go into the already
created text box on the form and open up the code window
to design something like above. all I want to do as a
project is to use the above code to look at a form match
the form with a table and add the tables fields to the
form automatically.
can I use it differently and how?
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(varState))Then Me![City] = varCity
End Sub
Here is my information:
I have a query turned into a form and a table.
Form name Copy of qry:CANTEST
boxes on form:
NEW CAN#
FY
Transaction Amount
My table name tbl:CANFY2003
Fields:
CAN
RESEARCH
DIVISION
POOL
Notes
I understand that there are other ways to accomplish this
but I want to use code and I'm trying to figure out if I
need to design a box on a form or go into the already
created text box on the form and open up the code window
to design something like above. all I want to do as a
project is to use the above code to look at a form match
the form with a table and add the tables fields to the
form automatically.