473,597 Members | 2,342 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.provin ce_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 2143
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.provin ce_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("Provin ceID","Province Table","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.openr ecordset(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
3069
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
8988
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 added a sample of that below (there would be many more rows). I'm wondering if there is a way to dynamically generate the variable names (ie: T1val, T2val, etc.) in my function 'calc', based on the argument 'regnum' that I pass it. The problem...
4
1706
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 alphabetically. Sometimes, this value happens to be on the top and SELECTED. The problem is that if this item is selected by clicking on it, in response to onChange I open a text field (so user can specify the value). If this field is automatically...
9
2923
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 ("document.forms."+rowString+".value")) == true ) { //this alert works if the value is a letter,i.e,"a" alert("You have entered an non-numeric value.\nEnter a number in the appropriate box.");
11
11980
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 order to manage the databases more efficiently. - I'm currently using MySQL 4.1.12 and I'm currently testing 5.0.14 - I have a databases for each user account. - Each database has the same schema and entity relation model.
0
1411
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 between tlkpFootnotes and tblFees which contains FK_Code & FK_Footnotes [unique Index set for these 2 fields).
5
8074
by: howa | last post by:
Hi, Consider a simple example, e.g. var a = { 'a': 'b', 'c': 'd' }
1
4506
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 combobox. The textbox column is going to be coming from a database (actually I could manually create it if i had to). It makes about 20 rows, each with a unique value for the textbox column. The available choices for the combobox row are coming from a...
0
8272
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8035
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8258
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6688
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
3886
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3927
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2404
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1494
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1238
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.