473,382 Members | 1,180 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,382 software developers and data experts.

How can i relate one field in a table with an other field of another table?

23
I have two table named 'stock' & 'delivery' with following fields-

stock-
1.product id
2.date
3.quantity

delivery
1.memo no
2.product id
3.date
4.quantity

I need whenever i input value in 'quantity ' field of "delivery" table it should search automatically, is that quantity available in "stock" table or not. if not available, a massage should appear like this "quantity not available" on moving to other field or button or on pressing tab or clicking any where of the form. PLZ give me a proper solution. thanx.....
Nov 11 '13 #1
4 1210
CJ_London
27 16bit
There are a number of ways you can do this however I would do the following:

in the after update event of your quantity control on your form put the following (change names to suit - txt... refers to the name of the control on your form):

Expand|Select|Wrap|Line Numbers
  1. Dim rst as Recordset
  2.  
  3. set rst=currentdb.openrecordset("SELECT quantity FROM Stock WHERE [Product id]=" & txtProductID)
  4. if rst.fields(0)-txtQuantity<0 then
  5.     msgbox "Only " & rst.fields(0) & "available, please reduce quantity"
  6. end if
Nov 11 '13 #2
moonrb
23
THANK U SO MUCH
BUT I CAN NOT UNDERSTAND THE BOLD PORTION BELOW. PLZ EXPLAIN


(change names to suit - txt... refers to the name of the control on your form):
1. Dim rst as Recordset
2.
3. set rst=currentdb.openrecordset("SELECT quantity FROM Stock WHERE [Product id]=" & txtProductID)
4. if rst.fields(0)-txtQuantity<0 then
5. msgbox "Only " & rst.fields(0) & "available, please reduce quantity"
6. end if
Nov 12 '13 #3
CJ_London
27 16bit
On your form where you are entering the quantity you will have selected a product. You have not said what the name of any of the controls on your form are called so to identify them I prefixed them with txt.

i.e. txtProductID should be replaced with the name of your productID control on your form
Nov 12 '13 #4
zmbd
5,501 Expert Mod 4TB
moonrb

Keep it simple... follow MS tutorial:
Create relationships for a new database

Once you have this down, please work thru this tutorial:
MS Access 2010 Tutorials Please create the project that this tutorial walks you thru. By doing so, you will learn a great deal about the basic concepts behind what Access is and is not.
Nov 14 '13 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Deja User | last post by:
This is probably very simple but I can't figure out a way to update one table from another table. Here is an example: ------ TABLEA ------ first_name last_name
1
by: Mike9900 | last post by:
What is the best way to copy DataRow from one table to another table, without copying its structure, which means copying only its data. -- Mike
1
by: thengfen | last post by:
Hi! Im having a problem in transfering a set of records from a table to another table. The scenario is when i select combo box (Course taken such as diploma in IT), then the process will...
1
by: Sakakini | last post by:
How can I append last entry from one table to another table???
4
by: xoozlez | last post by:
Hi there, How do I insert new records from a dbo table to another table? This is what I have: 1 dbo_company 1 Member (table) I made a query in dbo_company with the criteria I only want to...
3
by: anil2083 | last post by:
How to migrate the comma separated values from one table to another table? suppose we have table i.e XYZ and we have comma separated values in few columns i.e( column_name and values are...
3
by: shubham rastogi | last post by:
hello guys I want to copy or insert records into the previously created table from another table.. For example I have two tables A and B .... I want to copy or insert records from table B into...
2
by: amitsukte | last post by:
Hi Everyone how should i update multiple columns of a table from another table... Suppose I have table A and B and having four columns each table A(col1,col2,col3,col4) B(col1,col2,col3,col4) ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
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...

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.