K
Ken Ivins
I have a form in which I want to automatically fill in the zip code when the
town is selected from the combo box. I also need it flexible so towns and
zips can be added and modified (I can handle that part, I believe). Also
some cities have multiple zips and sometimes multiple towns share the same
zip.
So I created a table for this form called tblSubscriber and in a query
linked it with a table of tblPlans for this form. In addition I created a
table called tblCityPostal with the town names and their corresponding zip
codes.
On my form (frmSubscriber) I have a combo box for the cities that look to
tblCityPostal. The I created an After Update event to look to the table
tblCityPostal to paste the appropriate zip code to the zip code field (see
below).
Dim strZCode As String
strZCode = DLookup("[ctPostalCode]", "tblCityPostal", "[ctCity_Towns] ="
& Me!cmbCity)
Me!txbZip = strZCode
When I do this I get one of two errors (see below). I have tried many
combinations from saving the record, to moving the " and taking out the &,
to adding Forms!form name, to creating a string for the City name, all with
the same results. Any ideas what is causing this?
Run time error '2001'
You canceled the previous operation.
Run time error '3075'
Syntax error (missing operator) in query expression '[ctCity_Town]=Clifton
Park'.
Thanks,
Ken Ivins
town is selected from the combo box. I also need it flexible so towns and
zips can be added and modified (I can handle that part, I believe). Also
some cities have multiple zips and sometimes multiple towns share the same
zip.
So I created a table for this form called tblSubscriber and in a query
linked it with a table of tblPlans for this form. In addition I created a
table called tblCityPostal with the town names and their corresponding zip
codes.
On my form (frmSubscriber) I have a combo box for the cities that look to
tblCityPostal. The I created an After Update event to look to the table
tblCityPostal to paste the appropriate zip code to the zip code field (see
below).
Dim strZCode As String
strZCode = DLookup("[ctPostalCode]", "tblCityPostal", "[ctCity_Towns] ="
& Me!cmbCity)
Me!txbZip = strZCode
When I do this I get one of two errors (see below). I have tried many
combinations from saving the record, to moving the " and taking out the &,
to adding Forms!form name, to creating a string for the City name, all with
the same results. Any ideas what is causing this?
Run time error '2001'
You canceled the previous operation.
Run time error '3075'
Syntax error (missing operator) in query expression '[ctCity_Town]=Clifton
Park'.
Thanks,
Ken Ivins