473,387 Members | 3,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

relations in access

Hello,

I have a question about relations.
I have a table with city's and zipcodes. I need to insert these in an other
table when filling in a form. So far all works fine. But now i want it to
automatically fill in the city when i fill in the zipcode or vice versa. How
do I do this?

Greetings,
Kristof
Nov 12 '05 #1
1 1294
air code, no error code

in the city_afterUpdate event
dim rs as recordset
dim strsql as string

strsql = "SELECT zipCode FROM tblCityZip WHERE city = '" & city & "'"
set rs = currentdb.openrecordset(strsql)
if (not(rs.eof)) then
zip = rs!zip
end if
rs.close
set rs = nothing

same thing in the zip_afterUpdate event

and in the form_afterUpdate event
dim rs as recordset
dim strsql as string

strsql = "SELECT zipCode FROM tblCityZip WHERE city = '" & city & "'"
set rs = currentdb.openrecordset(strsql)
if (not(rs.eof)) then
' if zip is changed, could give user the choice of updating the table
rs.edit
rs!zip = zip
rs.update
else
rs.add
rs!city = city
rs!zip = zip
rs.update
end if
rs.close
set rs = nothing
"Kristof" <kr*************@pandora.be> wrote in message news:<06**********************@phobos.telenet-ops.be>...
Hello,

I have a question about relations.
I have a table with city's and zipcodes. I need to insert these in an other
table when filling in a form. So far all works fine. But now i want it to
automatically fill in the city when i fill in the zipcode or vice versa. How
do I do this?

Greetings,
Kristof

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Bose | last post by:
Hi I have to make export of SQL Server Database to MS Access and I have done it with the tables but now I need to transfer(export) the relations, keys and indexes. Can any1 tell me how to read...
1
by: Jef De Rycke | last post by:
Hi access group, I have written code to create relations between tables according to a corresponding relations information table. At first I thought my code was not working properly because...
1
by: nicolaas | last post by:
Hi everyone Is there someone out there who can tell me how to create relationships between tables using VB??? PS I am using MS ACCESS 2003 and I have read the help... THANK YOU
4
by: What-a-Tool | last post by:
I am trying to write a program that will take all the members of a data base, add them to a tree, with all child relations as sub-nodes. I am having a problem getting the parent child relations...
6
by: Lars Netzel | last post by:
I have a VB.NET application based on MS access 2000 db. I have a 1 to many relation between 4 tables... tbl1 -> tbl2 -> tbl3 -> tbl4 (all with "one to many" relations) I need to create a...
1
by: Randy Fraser | last post by:
How do I create a relationship on muliple columns in an untyped dataset. Why does this not work. da.Fill(ds) ds.Tables(0).TableName = "DesignSummary" ds.Tables(1).TableName = "FormulaSummary"...
0
by: peter mpa | last post by:
Greetings. I am building a c# windows forms app to show tables from a ms access database. I am using OleDbConnection with Microsoft.Jet.OLEDB.4.0 , 5 datagrids and some data relations to show on...
26
by: Allen Browne | last post by:
In Access 2000 and later, you can create a relation between tables where related records can be automatically set to Null rather than deleted when the primary record is deleted. I have not seen...
2
by: mcmahonb | last post by:
Hello people, I'm fairly new to access and DB programming in general. I am familiar with the "basics" of MS Access, forms, tables, queries, macros, and such, but still don't have everything down...
9
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New...
0
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$) { } ...
0
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...
0
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...
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
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...
0
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...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.