C
CM
Hi Repost.... Urgent help required...Thxs !
Hi everyone,
I am trying to use the code pasted below, which is designed to allow you to
automatically select the town and county based on what postcode you enter. I
have tried to revise the code based on the database that I have but to no
avail.
I have made a table called "tbl-postcodes" which I have three fields, first
one is "Postcode", then "Town" then "County"
I have tried the code listed underneath the original, but nothing seems to
work.
Thanks for any help anyone can give me, on this!
Colin
************* Code Start **************
' This code was originally written by Erika Yoxall.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Erika Yoxall
'
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
'************* Code End **************
The code I have used is the following....
Sub MembersPostcodeTextBox_OnExit(Cancel As Integer)
Dim varCounty, varTown As Variant
varState = DLookup("County", "tbl-postcodes", "Postcode =[Postcode] ")
varCity = DLookup("City", "tbl-postcodes", "Postcode =[Postcode] ")
If (Not IsNull(varCounty)) Then Me![County] = varCounty
If (Not IsNull(varTown)) Then Me![Town] = varTown
End Sub
My form contains the information from one table called "centralsystem" and I
have made a table called "tbl-postcodes" which has the following sample data
which I will finish off once I know it works
Field 1 is named Postcode
Field 2 is named Town
Field 3 is named County
In the rows it would be something like this...
SW1A 1AA Westminster London
PL1 1AA Plymouth Devon
BH1 1AA Bournemouth Dorset
However, when I try the postcodes in the form, I want it to automatically
pick the town and county, which is a selection in a combo box. It doesn't
save much time, I know but it all helps!
Thanks
Colin
Hi everyone,
I am trying to use the code pasted below, which is designed to allow you to
automatically select the town and county based on what postcode you enter. I
have tried to revise the code based on the database that I have but to no
avail.
I have made a table called "tbl-postcodes" which I have three fields, first
one is "Postcode", then "Town" then "County"
I have tried the code listed underneath the original, but nothing seems to
work.
Thanks for any help anyone can give me, on this!
Colin
************* Code Start **************
' This code was originally written by Erika Yoxall.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Erika Yoxall
'
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
'************* Code End **************
The code I have used is the following....
Sub MembersPostcodeTextBox_OnExit(Cancel As Integer)
Dim varCounty, varTown As Variant
varState = DLookup("County", "tbl-postcodes", "Postcode =[Postcode] ")
varCity = DLookup("City", "tbl-postcodes", "Postcode =[Postcode] ")
If (Not IsNull(varCounty)) Then Me![County] = varCounty
If (Not IsNull(varTown)) Then Me![Town] = varTown
End Sub
My form contains the information from one table called "centralsystem" and I
have made a table called "tbl-postcodes" which has the following sample data
which I will finish off once I know it works
Field 1 is named Postcode
Field 2 is named Town
Field 3 is named County
In the rows it would be something like this...
SW1A 1AA Westminster London
PL1 1AA Plymouth Devon
BH1 1AA Bournemouth Dorset
However, when I try the postcodes in the form, I want it to automatically
pick the town and county, which is a selection in a combo box. It doesn't
save much time, I know but it all helps!
Thanks
Colin