I have tried the following in my Zip_AfterUpdate:
If Not IsNull([Zip]) Then
Zip5 = Left([Zip], 5)
[City] = DLookup("ZipCity", "ZipList", "[zipID]='" & Zip5 & "'") 'check
the spacing carefully here for " and '
[ST] = DLookup("ZipST", "ZipList", "[zipID]= '" & Zip5 & "'")
If Trim([City]) = "" Or IsNull([City]) Then
CityFlag = True
City.SetFocus
Else
HPhone.SetFocus
End If
End If
and this in State_Exit:
If Len([Zip]) > 0 Then '9/28/01
If CityFlag Then
Zip5 = Left([Zip], 5)
CityString = [City]
STString = [ST]
DoCmd.OpenForm "ZipListForm", acNormal, , , acFormAdd
Forms![ZipListForm]![ZipID] = Zip5
Forms![ZipListForm]![ZipCity] = CityString
Forms![ZipListForm]![ZipST] = STString
DoCmd.Close
End If
End If
Thus, if the Zip is in the ZipList table, State and City are filled in,
otherwise (if cityflag is set) the new data typed in are added to the table
for the next time. Works for me...
Steve
Cheryl Fischer said:
Hi Mark,
Here is what I would do:
1. Make the control on your order form for zip code a combo box.
2. Set the properties of your combo box as follows:
Row Source: Select ZipCode, City, State from tblZipCodes Order by ZipCode
(change the field names and table name to correspond with your zip codes
table)
Column Count: 3
Bound Column: 1
Control Source: name of zipcode field in your Orders table
3. In the After Update event for your combo box, insert the following:
Me!City = Me!MyComboBox.Column(1)
Me!State = Me!MyComboBox.Column(2)
hth and post back if you have any questions,
--
Cheryl Fischer
Law/Sys Associates
Houston, TX
to
reference it so that when I'm in my order form, and tab off the completed
zip code field, that it will autofill the city and state. I'm sure this is
a basic question, but will someone please help me? Thanks in advance for
any advice.