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

Accessing a non-primary key field from one table to another

I am trying to grab the UnitPrice from Table 1 and store it in the
UnitPrice field in Table 2 whereever there is a match ProductID wise.
Table 1
[Products Table] - ProductID (Prim Key), ProductName, UnitPrice
Table 2
[Order Details Table] - OrderID (Prim Key), ProductID (Prim Key),
UnitPrice, Quantity
In the [Order Details Table] I have accessed the ProductName from the
[Products Table] by establishing a Many-to-One relationship and using a

lookup column.
[Order Details Table] is the "Many"
[Products Table] is the "One"
The problem that I am having is that the UnitPrice in the [Order
Details Table] cannot access the UnitPrice in the [Products Table].
Is there any way for the [Order Details Table] to access the
"UnitPrice" from the [Products Table] and store it in its own
"UnitPrice" field for each order detail in the [Order Details Table]?

Nov 13 '05 #1
3 1958
Yes. It's called a query. =)

Nov 13 '05 #2
I have already tried a query. The [Order Details Table]'s UnitPrice
field continuously displays $0.00.

I just want the UnitPrice field in the [Order Details Table] to have
the same value of the UnitPrice field in the [Products Table].

Nov 13 '05 #3
so your goal is to get the *current* price at the time of the sale (so
if the price changes later in the Products table, your past Invoice
totals won't get hosed)?

You could use DLookup to set the price. If you download the Northwind
sample database form the MS site, there's an example of it in the
Orders subform. If you open that in design view, you'll see this
code... (well, among other things)

Private Sub ProductID_AfterUpdate()
On Error GoTo Err_ProductID_AfterUpdate

Dim strFilter As String

' Evaluate filter before it's passed to DLookup function.
strFilter = "ProductID = " & Me!ProductID

' Look up product's unit price and assign it to UnitPrice control.
Me!UnitPrice = DLookup("UnitPrice", "Products", strFilter)

Exit_ProductID_AfterUpdate:
Exit Sub

Err_ProductID_AfterUpdate:
MsgBox Err.Description
Resume Exit_ProductID_AfterUpdate

End Sub

What's happening is that the price *at the time of the sale* is being
looked up and *copied* into the subform. The version of the database I
found on their website was for (I think) Access 2000, but you can
convert it easily enough...

Nov 13 '05 #4

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

Similar topics

14
by: sachin_mzn | last post by:
Hi, Why I am not getting any run time error while accessing a freed memory in following code. This is printing h in std output. #include<stdio.h> main() { char* buffer = (char*)malloc(6);...
7
by: David Laub | last post by:
I've also posted this issue to a Sun/java formum, but since it appears to be an integration issue, this may be the better place to posr: I have written a dot net/c# Web Services doesn't fully...
8
by: Ben Fidge | last post by:
Hi I have a small WinForms app that needs to copy files from a shared drive on a network. If I connect to the mapped drive using Explorer, a password dialog pops-up and I have to provide...
3
by: Olivier BESSON | last post by:
Hello, I have a web service of my own on a server (vb.net). I must declare it with SoapRpcMethod to be used with JAVA. This is a simple exemple method of my vb source : ...
1
by: mark kurten | last post by:
i have a asp.net site that is causing problems for users accessing it using a proxy server. does anyone know of any limitations the proxy might have? or anything else that would effect the proxy...
10
by: amazon | last post by:
Our vender provided us a web service: 1xyztest.xsd file... ------------------------------------ postEvent PostEventRequest ------------------------------------- authetication authentication...
3
by: sam | last post by:
hello all, i am currently in the process of planning a piece of software to model polymerisation kinetics, and intend to use python for all the high-level stuff. the number-crunching is...
0
by: tmanikandaraja | last post by:
I want to have a clarification on some data access scenarios with DB2 as data source I have CICS modules accessing DB2 currently with embedded functional logic and they do non-atomic...
10
by: Anton | last post by:
Hi, when accessing a secured 3rd party webservice i'm getting a 401 HTTP Statuscode (unauthorized). When entering the url in a browser and entering the username and password manually, the wsdl is...
2
by: =?Utf-8?B?SklNLkgu?= | last post by:
Accessing AD in ASP.Net 1. It sees I can I access Active Directory catalog from asp.net, is the version of AD important for this? 2. Do I need to have a domain user for that or IIS will be...
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
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
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,...
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
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,...

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.