I have an Access DB that I'm looking to have the City, State, and some other info auto populate after I type the Zip. I am VERY VERY new to Access and am teaching myself. I don't know VB and would need to be walked through step by step. Any help would be possible.
Thanks
15 9347
Heya, imnotsmart. Welcome to TSDN!
I'm going to go ahead and move this thread to the Access forum, where our resident Experts will be better able to help you out.
Is it safe to assume you have a table listing all cities, states, and zip code?
Is it safe to assume you have a table listing all cities, states, and zip code?
Yes. I have the table with all the Towns, Cities, Zips and other info I need.
In the after update event of the zip code control you'd have something along the lines of: -
Private Sub txtZip_AfterUpdate()
-
txtCity = DLookup("City", "tbl_ZipCityState", "Zip = " & Me.txtZip)
-
txtState = DLookup("State", "tbl_ZipCityState", "Zip = " & Me.txtZip)
-
End Sub
-
This assumes zip is a numeric data type.
The Zip is a text data type (Zip codes in NJ start with 0. If its numeric the 0 gets dropped). The table is called City. The fields are City, State, Zip. So based on what you posted before, I tried this:
Private Sub Zip_AfterUpdate()
txtCity = DLookup("City", "tbl_City", "Zip = " & Me.txtZip)
txtState = DLookup("State", "tbl_City", "Zip = " & Me.txtZip)
End Sub
When I go back to the form, I get the following error.
Compile error:
Method or data member not found
.txtZip on line 2 is highlighted in blue and the first line is highlighted in yellow.
If Zip's text then you'll need to do: -
"Zip = '" & Me.txtZip & "'"
-
txtZip, txtCity, and txtState are in reference to the controls on your form, I doubt that's what you named them so you'll have to change those to match.
Thanks!! I played with it a little and got it to work.
Now, another question. I have yes/no buttons associated with each town and a number. Is the code the same or does it change.
Thanks!! I played with it a little and got it to work.
Now, another question. I have yes/no buttons associated with each town and a number. Is the code the same or does it change.
I'm not following, can you go into more detail?
Nevermind, I figured it out.
But I have another question. I need the info that populates in the City, State and Zip field to fill in City, State, and Zip fields in another table. Don't know if this is possible.
Nevermind, I figured it out.
But I have another question. I need the info that populates in the City, State and Zip field to fill in City, State, and Zip fields in another table. Don't know if this is possible.
You mean into an additional table? You'll need to use DoCmd.RunSQL "INSERT INTO ..."
Yes, into an additional table called People.
Ok, then try out what I suggested in post #11.
Not sure how to do it. Can you give a little more. Here is some more info.
After the City, State, and Zip are entered for a Person in my form, I need the City, State, and Zip to also show up under that Person in a different table.
Not sure how to do it. Can you give a little more. Here is some more info.
After the City, State, and Zip are entered for a Person in my form, I need the City, State, and Zip to also show up under that Person in a different table.
What you'll want to do is, in the after update event of each of the fields, check that all 3 fields are populated, i.e. not null. Then you want to check to see if a record already exists in the other table. If it does, you use DoCmd.RunSQL "UPDATE SQL String". If not, you use a DoCmd.RunSQL "INSERT INTO SQL Append String"
I found this interesting and was wondering if it could be expended a bit.
My table of zip codes has Primary City Name [PrimaryCityName] and Acceptable City Names [AcceptableCityNames]. I'd like for the code to change the [City] control on the form to an option drop down showing the alternative Acceptable City Names that the user could then select from. The acceptable city names are stored comma separated so sometimes they will have multiple acceptable city names to select from. Both are Short Text data types.
Here is my code pulling just the three things I want to use but I don't know how to code the options part of it. -
Private Sub ZIP_Code_AfterUpdate()
-
-
City = DLookup("PrimaryCityName", "tblZipCodes", "ZipCode = '" & Me.[ZIP Code] & "'")
-
-
State = DLookup("StateCode", "tblZipCodes", "ZipCode = '" & Me.[ZIP Code] & "'")
-
-
Country = DLookup("Country", "tblZipCodes", "ZipCode = '" & Me.[ZIP Code] & "'")
-
-
End Sub
Thanks,
Terry
Sign in to post your reply or Sign up for a free account.
Similar topics
by: B. G. Mahesh |
last post by:
hi
In the registration form I have city, state, country fields. I was
wondering if there was a database available on the net which has the
list of states in each of the countries. That way when...
|
by: Mike McGee |
last post by:
I am new to database apps, but I am making a db with access 2002. Here is
what I have and what I would like for it to do.
tblCustomers = holds customer info (Name, Address, City, State, Zip,...
|
by: Namratha Shah \(Nasha\) |
last post by:
Hey Guys,
Today we are going to look at Code Access Security.
Code access security is a feature of .NET that manages code depending on its
trust level. If the CLS trusts the code enough to...
|
by: Sree |
last post by:
hello people,
Can any body give me the code or the basic logic to
enter and also access data from a Database management system using
C?...also tell me the actuall syntax to run an .exe file using...
|
by: Simon Hart |
last post by:
Does anyone know the standard code access permission to be able to
manipulate a process using the Process class?
Thanks
Simon.
|
by: greg.scharlemann |
last post by:
Does anyone know where I could find a complete city and state database
for MySQL?
I've looked at the Zip Code data on the census website, but don't know
the best approach to get a .dbf file into...
|
by: colleen1980 |
last post by:
Hi:
Can any one please tell me how do i separate city state and zip. I ask
this question in previous post. But when the city name is in two words
it mess up my values otherwise it works.
...
|
by: cfish |
last post by:
I'm trying to script my contact page and I have everything the way I want it however I cannot get my script to output Address, City, State, Zip & Phone Number when I get a email. It will output...
|
by: rizwanrazzaq |
last post by:
Hi friends here is my coding.. but i m facing one problem .. i used both mathod SQL mathod and open Record Set. but in both i m getting error massage can anyone help me out regarding thi.
Please...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |