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

HOW TO UPDATE A TABLE BASED ON CHANGES IN ANOTHER TABLE?

EKL
Hi,

I'm making a sort of Customer and Orders database in MS Access 2003. My
problem is that I wish to update the table "tblTransaction" based on changes
made in the table "tblOrderDetails". There is no direct relationship between
these two tables. The "tblProducts" has a one-to-many relationship to "
tblOrderDetails" and "tblTransaction". I use the "tblTransaction" to count
number of items in stock for each product. I therefore wish to update this
table when "tblOrderDetails" changes, so that my "items in stock" is
dynamically updated.

I have found out that Access don't have record triggers at the table level
like Oracle does. But I assume that my problem can be solved with some
Visual Basic Event Procedures in the form I use to input my Orders and
OrdersDetails.

The form I use for this is called "frmPrivateUser" and contains two sub
forms, "frmOrdersSubform" and "frmOrderDetailsSubform". "frmOrdersSubform"
contains information about the order and "frmOrderDetailsSubform" contains
this orders products. "frmOrderDetailsSubform" is linked to
"frmOrdersSubform" on the field "OrderID"(an auto number).

When I add a record in the form I want to take some of the values from the
forms and place them in "tblTransaction". I also need to place these values
differently based on some values in "frmOrdersSubform"(Order type). I also
want to check the ProductID against the "tblProducts" to see if a product is
a physical unit and not a service(Attribute Lagervare=yes in tblProducts) .
If the product is not a physical unit there is no need to add transactions.
Depending on the type of order I want to take the following values from my
forms and put it in "tblTransaction:

The controls on my form are:

"frmOrdersSubform": Ordernr and OrderType

"frmOrderDetailsSubform": ProductID and NumberOfUnits

If OrderType="Innhenting" in frmOrdersSubform then set:

tblTransaction

TransactionID (autonumber)

Transactiondate =Date()

Transactiontype ="Oppdrag"

UnitsIn =value of control "NumberOfUnit"s
in "frmOrderDetailsSubform"

UnitsOut ="0"

Ordernr = value of control "Ordernr" in
"frmOrdersSubform"

ProductID = value of control "ProductID" in "
frmOrderDetailsSubform"

Else set:

tblTransaction

TransactionID (autonumber)

Transactiondate =Date()

Transactiontype ="Oppdrag"

UnitsIn ="0"

UnitsOut = value of control "NumberOfUnit"s
in "frmOrderDetailsSubform"

Ordernr = value of control "Ordernr" in
"frmOrdersSubform"

ProductID = value of control " ProductID"s in "
frmOrderDetailsSubform"

When I delete a record from "frmOrderDetailsSubform" any records in
"tblTransaction" with the same Ordernr AND ProductID should be deleted (if
they exist).

When I update a record from "frmOrderDetailsSubform" any records in
"tblTransaction" with the same Ordernr and ProductID should be deleted (if
they exist), and the updated values should add a new record in
"tblTransaction"

Any code suggestions? What Events do I need to use? Should these Events be
placed in the "frmOrderDetailsSubform"?

Thanks for all help....
Nov 13 '05 #1
0 1870

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

Similar topics

16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
1
by: Trent | last post by:
Hello,everyone. I'm setting a db2 replication environment using UDB version 8.1.5 running on Windows 2000 servers. The source server is on a Windows server with the capture program running while...
9
by: Dom Boyce | last post by:
Hi First up, I am using MS Access 2002. I have a database which records analyst rating changes for a list of companies on a daily basis. Unfortunately, the database has been set up (by my...
1
by: Ryan | last post by:
Hello, I have a quick question (I hope). I have a form with a combo box and a multi-selection list box. The list box is based on a query. Users can select values from the cmbobox to add to...
0
by: M. David Johnson | last post by:
I cannot get my OleDbDataAdapter to update my database table from my local dataset table. The Knowledge Base doesn't seem to help - see item 10 below. I have a Microsoft Access 2000 database...
0
by: Manish | last post by:
Hey Guys I am using a datagrid to extract information out of SQL Server datbase. The fields extracted are category,week,budget,Last Year,Forecast and Projection. Also i add a calculated column...
16
by: Ian Davies | last post by:
Hello Needing help with a suitable solution. I have extracted records into a table under three columns 'category', 'comment' and share (the category column also holds the index no of the record...
0
by: Access Programming only with macros, no code | last post by:
ERROR MESSAGE: Could not update; currently locked by another session on this machine. BACKGROUND I have the following objects: Table1 - HO (which has about 51,000+ records) Table2 -...
2
by: BobLewiston | last post by:
Some of you may have seen my earlier thread “PasswordHash NULL problem”. I’ve started a new thread because investigation has shown that the problem is actually quite different than I previously...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: 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
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.