473,387 Members | 1,549 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.

automatically assign a value based on another value

Here's my problem:
I've got a table cities with the following tables: zipcode, city, province
and table provinces: a table with: province_id, provincename
cities.province and province.province_id are linked.
Is there anay way to automatically fill in the cities.province value based
on the cities.zipcode value?
For example: if the value in zipcode is between 1000 and 2000, then the db
should fill in "1" in province?

Thanks in advance

--
stijn.verspeet@pandora[delete.this].be
Nov 12 '05 #1
1 2132
TRAX wrote:
Here's my problem:
I've got a table cities with the following tables: zipcode, city, province
and table provinces: a table with: province_id, provincename
cities.province and province.province_id are linked.
Is there anay way to automatically fill in the cities.province value based
on the cities.zipcode value?
For example: if the value in zipcode is between 1000 and 2000, then the db
should fill in "1" in province?

Thanks in advance

--
stijn.verspeet@pandora[delete.this].be


If a small list, you could use Select Case
Select case zipcoce
Case 1000 to 2000
Me.Province = 1
Case 2001 to 3000
Me.provice = 2
Case Else
Me.Provice = 3
End Select

I'm not sure how many tables you have. However, if you can somehow link the
proviince id to the zipcode, you can use Dlookup() as one method. Or use a
recordset.

Me.Province = Dlookup("ProvinceID","ProvinceTable","your filter to find
province)

or
DIm strSQL As String
Dim rst As Recordset
strSql = "Select ProviceID from ProvinceTable Where your filter
condition...."
Set rst = Currentdb.openrecordset(strSQL,dbopensnapshot)
If rst.RecordCount > 0 then Me.ProviceID = rst!ProviceID
rst.close
set rst = Nothing

You can place any of these in the AfterUpdate event of the zipcode.
Nov 12 '05 #2

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

Similar topics

2
by: reneeccwest | last post by:
Different user input boxes are automatically populated based on a value of the dropdown box. Can anyone help me on that?
4
by: Terry | last post by:
I have a number of input boxes used to display totals based on selected items for each row in a table. There are more than a few rows that are identical, except for the form field name. I have...
4
by: Xerxes | last post by:
Hi, can I have a field automatically clicked by calling something like click()? I have a dropdown box, one of whose elements is "Others (Please Specify)". I list the dropdown boxes values...
9
by: ckerns | last post by:
I want to loop thru an array of controls,(39 of them...defaults = 0). If value is null or non-numeric I want to assign the value of "0". rowString = "L411" //conrol name if (isNaN(eval...
11
by: Matt | last post by:
Hi everyone, still pretty new to MySQL. I was wondering if there is a way to automatically filter records based on a mysql userlogin name?? I have serveral databases that I want to combine in...
0
by: amywolfie | last post by:
Hi all: I have a subform called sfrmFootnotes linked to main Form frmFeeInput (the latter based on tblFees). tlkpFootnotes contains the PK for Footnotes. tjnCode_Footnotes is a join table...
5
by: howa | last post by:
Hi, Consider a simple example, e.g. var a = { 'a': 'b', 'c': 'd' }
1
Plater
by: Plater | last post by:
I feel like this question has been asked before, but I couldn't find it. I think I am missing something obvious. Basically I am going to have a DataGridView with two columns. One textbox, one...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.