wwwredback
Registered User.
- Local time
- Today, 09:09
- Joined
- Apr 28, 2009
- Messages
- 37
Sorry but it is a long question:
I am using MS Access 2003.
In a Form called: Orders I have a drop down combo box as shown below:
cboAccountType
Account
Trade
DIY
If you select Account from cboAccountType I need to pull the following fields and add them into the subform: OrdersSubform
OrderID from tbl_OrderDetails
ProductID from tbl_OrderDetails
Quantity from tbl_OrderDetails
Discount from tbl_OrderDetails
ProductName from tbl_Products
UnitPrice from tbl_Products
If you select Trade from cboAccountType I need to pull the following fields and add them into the subform: OrdersSubform
OrderID from tbl_OrderDetails
ProductID from tbl_OrderDetails
Quantity from tbl_OrderDetails
Discount from tbl_OrderDetails
ProductName from tbl_Products
TradePrice from tbl_Products
If you select DIY from cboAccountType I need to pull the following fields and add them into the subform: OrdersSubform
OrderID from tbl_OrderDetails
ProductID from tbl_OrderDetails
Quantity from tbl_OrderDetails
Discount from tbl_OrderDetails
ProductName from tbl_Products
DIYPrice from tbl_Products
On the On Change property I have the following [Event Procedure]:
Private Sub AccountType_Change()
If Me.AccountType = "Account" Then
Me!OrdersSubform.Form.RecordSource = "Query1"
ElseIf Me.AccountType = "Trade" Then
Me!OrdersSubform.Form.RecordSource = "Query2"
Else
Me!OrdersSubform.Form.RecordSource = "Query3"
End If
End Sub
Here are the queries:
Query1
SELECT DISTINCTROW [Order Details].OrderID, [Order Details].ProductID, Products.ProductName, Products.UnitPrice, [Order Details].Quantity, [Order Details].Discount, CCur([Order Details].UnitPrice*[Quantity]*(1-[Discount])/100)*100 AS ExtendedPrice
FROM Products INNER JOIN [Order Details] ON Products.ProductID = [Order Details].ProductID
ORDER BY [Order Details].OrderID;
Query2
SELECT DISTINCTROW [Order Details].OrderID, [Order Details].ProductID, Products.ProductName, Products.TradePrice, [Order Details].Quantity, [Order Details].Discount, CCur(products.TradePrice*[Quantity]*(1-[Discount])/100)*100 AS ExtendedPrice, Products.TradePrice AS UnitPrice
FROM Products INNER JOIN [Order Details] ON Products.ProductID = [Order Details].ProductID
ORDER BY [Order Details].OrderID;
Query3
SELECT DISTINCTROW [Order Details].OrderID, [Order Details].ProductID, Products.ProductName, Products.DIYPrice, [Order Details].Quantity, [Order Details].Discount, CCur(Products.DIYPrice*[Quantity]*(1-[Discount])/100)*100 AS ExtendedPrice, Products.DIYPrice AS UnitPrice
FROM Products INNER JOIN [Order Details] ON Products.ProductID = [Order Details].ProductID
ORDER BY [Order Details].OrderID;
When I run this combo box it always picks up the UnitPrice whatever you choose from the combo box and then updates that price into whatever selection you have made.
i.e. if a rudgwick brick is
$0.15 for UnitPrice
$0.35 for TradePrice
$0.45 for DIYPrice
And I have selected Trade from the cboAccountType it will display the UnitPrice $0.15 instead of $0.35 and then when I look at the tbl_Products Table it has updated the TradePrice field for rudgwick bricks to $0.15
Why is this? What am I doing wrong?
Thank you so much in advance for any pointers.
I would also like to say a big thanks to john big booty for his help on this so far.
Cheers
James.
I am using MS Access 2003.
In a Form called: Orders I have a drop down combo box as shown below:
cboAccountType
Account
Trade
DIY
If you select Account from cboAccountType I need to pull the following fields and add them into the subform: OrdersSubform
OrderID from tbl_OrderDetails
ProductID from tbl_OrderDetails
Quantity from tbl_OrderDetails
Discount from tbl_OrderDetails
ProductName from tbl_Products
UnitPrice from tbl_Products
If you select Trade from cboAccountType I need to pull the following fields and add them into the subform: OrdersSubform
OrderID from tbl_OrderDetails
ProductID from tbl_OrderDetails
Quantity from tbl_OrderDetails
Discount from tbl_OrderDetails
ProductName from tbl_Products
TradePrice from tbl_Products
If you select DIY from cboAccountType I need to pull the following fields and add them into the subform: OrdersSubform
OrderID from tbl_OrderDetails
ProductID from tbl_OrderDetails
Quantity from tbl_OrderDetails
Discount from tbl_OrderDetails
ProductName from tbl_Products
DIYPrice from tbl_Products
On the On Change property I have the following [Event Procedure]:
Private Sub AccountType_Change()
If Me.AccountType = "Account" Then
Me!OrdersSubform.Form.RecordSource = "Query1"
ElseIf Me.AccountType = "Trade" Then
Me!OrdersSubform.Form.RecordSource = "Query2"
Else
Me!OrdersSubform.Form.RecordSource = "Query3"
End If
End Sub
Here are the queries:
Query1
SELECT DISTINCTROW [Order Details].OrderID, [Order Details].ProductID, Products.ProductName, Products.UnitPrice, [Order Details].Quantity, [Order Details].Discount, CCur([Order Details].UnitPrice*[Quantity]*(1-[Discount])/100)*100 AS ExtendedPrice
FROM Products INNER JOIN [Order Details] ON Products.ProductID = [Order Details].ProductID
ORDER BY [Order Details].OrderID;
Query2
SELECT DISTINCTROW [Order Details].OrderID, [Order Details].ProductID, Products.ProductName, Products.TradePrice, [Order Details].Quantity, [Order Details].Discount, CCur(products.TradePrice*[Quantity]*(1-[Discount])/100)*100 AS ExtendedPrice, Products.TradePrice AS UnitPrice
FROM Products INNER JOIN [Order Details] ON Products.ProductID = [Order Details].ProductID
ORDER BY [Order Details].OrderID;
Query3
SELECT DISTINCTROW [Order Details].OrderID, [Order Details].ProductID, Products.ProductName, Products.DIYPrice, [Order Details].Quantity, [Order Details].Discount, CCur(Products.DIYPrice*[Quantity]*(1-[Discount])/100)*100 AS ExtendedPrice, Products.DIYPrice AS UnitPrice
FROM Products INNER JOIN [Order Details] ON Products.ProductID = [Order Details].ProductID
ORDER BY [Order Details].OrderID;
When I run this combo box it always picks up the UnitPrice whatever you choose from the combo box and then updates that price into whatever selection you have made.
i.e. if a rudgwick brick is
$0.15 for UnitPrice
$0.35 for TradePrice
$0.45 for DIYPrice
And I have selected Trade from the cboAccountType it will display the UnitPrice $0.15 instead of $0.35 and then when I look at the tbl_Products Table it has updated the TradePrice field for rudgwick bricks to $0.15
Why is this? What am I doing wrong?
Thank you so much in advance for any pointers.
I would also like to say a big thanks to john big booty for his help on this so far.
Cheers
James.