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

dlookup unitprice based on customer and product

mseo
181 100+
hi,
I have a form/subform for adding orders, the problem that the prices are different from one customer to another, what I need to do is: dlookup the unitprice when I select a product and a customer from the comboboxes

thank you very much
Any help would be appreciated
Sep 10 '10 #1

✓ answered by liimra

Suppose you have 1,000 customers, it is not applicable to assign different price for each of them because we are talking about a system here and please note that all Accounting Systems I worked with don't have more than 10 price levels (why would there be more!). So, for example you would charge 10% above cost price for 200 of them, 15% above cost price for another 200.. and so on. (Note that you might want to set base price and give discount to each group). Of course you have to decide on the criteria for the groups, for example GroupA would be customers with above $0.5Millions turnover/year, GroupB would be Cash Customers and so on... Or GroupA would be first class customers and so on. Groups here are the same as levels. Whenever you create new customer you choose his/her group (pricing level).


So we add text field (group field/ price level field) to Customers' table.


Suppose you create 5 different groups, then you have to create 5 fields (price field) in the product table. (If you create 6 groups, 6 fields are required and so on. I think you should try to shrink your categories the maximum you can).

Whenever you enter a new product, you will have to enter all 5 different prices (of course this can be easily done using VB, so for example when you enter cost all 5 fields will be populated as cost*1.1,cost*1.2 and so on).


Of course, there will be transaction table which will be handling customers transactions. In this table, the required fields are: TransactionID, CustomerID, ProductID, Date(maybe), Quantity, Price (Of course you can add what else you need).

Although I think you have full idea about relations and although it is not our concern here, but let me just state it hoping it will be helpful for others. You have to link Transaction table to both Customers & Products Tables through One-to-Many relationship:
CustomerID (from Customer Table)-to-CustomerID (from transaction table)
ProductID (from Product Table)-to-ProductID (from Product table).



Now you create the transaction form with two ComboBoxes, Customer and Product. When you choose the customer, you populate the CustomerID field in the Transaction Table with the CustomerID from the Customer Table; same applies to the ProductID. The price will be based on the Customer and the Product chosen. Of course, the quantity will be entered manually while you might set the default value Date() as for the date field.

To set values, you can use macros (AfterUpdate Event) --> SetValue would be the "Action", FieldName of the field to be Updated is the "Item" and ComboName.Column(0) would be is the "Expression" value.
Example: Suppose you have Combo called "Cbo" which has three columns in its record source and ID is the first field, and the Field to be updated with the ID called "Fld", then the Item would be [Fld] and the expression would be Cbo.Column(0). If the ID is the second column then the expression becomes Cbo.Column(1) and so on.
To update the price field based on the users selection, you use IIf() or Switch(). For example: Suppose you have the other product combo box named Cbo2 (this Combo should have Product different prices),the expression would be:
Expand|Select|Wrap|Line Numbers
  1. IIF(Cbo.Column(0)="GroupA",Cbo2.Column(2),IIF(Cbo.Column(0)="GroupB",Cbo2.Column(3)))....
In Case of using VB, then it becomes
Expand|Select|Wrap|Line Numbers
  1. Fld = IIF(Cbo.Column(0)="GroupA",Cbo2.Column(2),IIF(Cbo.Column(0)="GroupB",Cbo2.Column(3)))
All what I stated is reflected in the attached database. Note that one thing I added there is that the user has to select the customer first because the price will be set after selecting the product; So in case he/she selects the product first - msgbox will popup and the Product Combo is Set back to Null. Another thing is that I used the Switch() Function for setting the price but you can use the IIf() Function instead. Moreover, all ID fields are hidden on the form as the user has nothing to do with them and they are populated automatically. In addition, all prices will be populated based on the cost price when entering new product. Finally, please enable the content of the database when you open it (it was created as accdb and then saved as mdb).


Regards,
Ali

8 3959
liimra
119 100+
One Question: If you have different prices for products and customers, wouldn't that make it very much complicated as you might have 100 different customers? wouldn't it be easier to set prices based on Customer Groups?

Anyways, Suppose you have three customers CuA, CuB & CuC and two products ProductA & ProductB. Furthermore, CuA & CuB have 30% discount while CuC doesn't; in this case you can populate the selling price field after updating the second combo (supposedly customer). To do this, add something like this to the "Afterupdate Event" of the second combo box:

Expand|Select|Wrap|Line Numbers
  1.  Price = IIf([Customer]="CuA" Or [Customer]="CuB",DLookUp("Price","TableName","[Product] = '" & [Product] & "'")*0.7,DLookUp("Price","TableName","[Product] = '" & [Product] & "'"))
and so on...

Regards,
Ali
Sep 10 '10 #2
mseo
181 100+
thank you very much Ali
I really appreciate your reply
you analysed the problem correctly
but, because we have numerous customers and products and thus we will have more than one price for the same product depending on the number of customers, so I can't use iif function to implement your approach
we need more dynamic solution for this problem

thanks and over again
MSEO
Sep 10 '10 #3
liimra
119 100+
You are most welcome. I don't know what you mean by "number of customers" because if you are choosing the customer from a combobox, how would there be a number!

Anyways, it is important to state here that I have created very complicated databases and I have never had any idea there is any other approach to different scenarios but the Nested IIF() & Switch() (both do the job); and what you want is to have different prices for different combination (scenarios).

Another approach is to save the prices in tables when creating the product. Again, this requires grouping customers because otherwise it is not applicable. In this approach, you create "GroupID" field in the customers table; and a number of price fields, to state different pricing for different groups (example: BasePrice, PriceA, PriceB, PriceC..and so on), in the product table. One good thing about this approach is that you don't need to change the Expression used in the first approach every time you create new group but instead, you create additional price field in the product table. Note: Saving prices increases database size.

Hope this helps,

Regards,
Ali
Sep 10 '10 #4
mseo
181 100+
hi,
thank again
I mean by number of customer (I can use iif function statically) which means I need to handle this programatically (something like Dcount or Dlookup)
here's the metadata of tbl_products
Expand|Select|Wrap|Line Numbers
  1. productID;autonumber;PK
  2. Productname;String
  3. Customer_ID;Number;FK
  4. UnitPrice;Number
  5.  
I have before update trigger to prevent duplicating records (something like compound index on the productname and custome_ID)
so,I don't to group customers
I just need to get the price of a product for specific customer

thank you
MSEO
Sep 10 '10 #5
liimra
119 100+
You are welcome again MSEO. According to my point of view, the two approaches I stated before serve the point (easy & applicable), but again this is my point of view which is different to yours. I hope some of the great contributors would offer different suggestions.


Best Regards,
Ali
Sep 10 '10 #6
mseo
181 100+
Ok, Ali
I am trying to implement your approach
I need one more thing, please provide me with more explanation and details about how I can implement it, because I am not fully grasped it, and that would result in design changes
thank you again and over again
I really appreciate your help
MSEO
Sep 10 '10 #7
liimra
119 100+
Suppose you have 1,000 customers, it is not applicable to assign different price for each of them because we are talking about a system here and please note that all Accounting Systems I worked with don't have more than 10 price levels (why would there be more!). So, for example you would charge 10% above cost price for 200 of them, 15% above cost price for another 200.. and so on. (Note that you might want to set base price and give discount to each group). Of course you have to decide on the criteria for the groups, for example GroupA would be customers with above $0.5Millions turnover/year, GroupB would be Cash Customers and so on... Or GroupA would be first class customers and so on. Groups here are the same as levels. Whenever you create new customer you choose his/her group (pricing level).


So we add text field (group field/ price level field) to Customers' table.


Suppose you create 5 different groups, then you have to create 5 fields (price field) in the product table. (If you create 6 groups, 6 fields are required and so on. I think you should try to shrink your categories the maximum you can).

Whenever you enter a new product, you will have to enter all 5 different prices (of course this can be easily done using VB, so for example when you enter cost all 5 fields will be populated as cost*1.1,cost*1.2 and so on).


Of course, there will be transaction table which will be handling customers transactions. In this table, the required fields are: TransactionID, CustomerID, ProductID, Date(maybe), Quantity, Price (Of course you can add what else you need).

Although I think you have full idea about relations and although it is not our concern here, but let me just state it hoping it will be helpful for others. You have to link Transaction table to both Customers & Products Tables through One-to-Many relationship:
CustomerID (from Customer Table)-to-CustomerID (from transaction table)
ProductID (from Product Table)-to-ProductID (from Product table).



Now you create the transaction form with two ComboBoxes, Customer and Product. When you choose the customer, you populate the CustomerID field in the Transaction Table with the CustomerID from the Customer Table; same applies to the ProductID. The price will be based on the Customer and the Product chosen. Of course, the quantity will be entered manually while you might set the default value Date() as for the date field.

To set values, you can use macros (AfterUpdate Event) --> SetValue would be the "Action", FieldName of the field to be Updated is the "Item" and ComboName.Column(0) would be is the "Expression" value.
Example: Suppose you have Combo called "Cbo" which has three columns in its record source and ID is the first field, and the Field to be updated with the ID called "Fld", then the Item would be [Fld] and the expression would be Cbo.Column(0). If the ID is the second column then the expression becomes Cbo.Column(1) and so on.
To update the price field based on the users selection, you use IIf() or Switch(). For example: Suppose you have the other product combo box named Cbo2 (this Combo should have Product different prices),the expression would be:
Expand|Select|Wrap|Line Numbers
  1. IIF(Cbo.Column(0)="GroupA",Cbo2.Column(2),IIF(Cbo.Column(0)="GroupB",Cbo2.Column(3)))....
In Case of using VB, then it becomes
Expand|Select|Wrap|Line Numbers
  1. Fld = IIF(Cbo.Column(0)="GroupA",Cbo2.Column(2),IIF(Cbo.Column(0)="GroupB",Cbo2.Column(3)))
All what I stated is reflected in the attached database. Note that one thing I added there is that the user has to select the customer first because the price will be set after selecting the product; So in case he/she selects the product first - msgbox will popup and the Product Combo is Set back to Null. Another thing is that I used the Switch() Function for setting the price but you can use the IIf() Function instead. Moreover, all ID fields are hidden on the form as the user has nothing to do with them and they are populated automatically. In addition, all prices will be populated based on the cost price when entering new product. Finally, please enable the content of the database when you open it (it was created as accdb and then saved as mdb).


Regards,
Ali
Attached Files
File Type: zip Combo.zip (34.2 KB, 136 views)
Sep 11 '10 #8
liimra
119 100+
Glad it worked for you.

Regards,
Ali
Sep 18 '10 #9

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

Similar topics

7
by: Spammay Blockay | last post by:
Does anybody know of a solid Java-based email list management product? - Tim --
0
by: ESmith | last post by:
I have an application that is based on v2.0 framework. My application needs to be deployed as a link on the user's organizations website. I thought I read somewhere that we are only allowed to...
1
by: deejayquai | last post by:
Hello I'm trying to append a series of values into fields from one table to another based on highlighted rows in a multi-select listbox. I'm stuck however when I need to append a couple of...
3
by: OlyOil | last post by:
I have two tables one with a bill of materials and one with the inventory quantities. The bill of materials table contains part numbers that would be found in the inventory table, and I am trying...
0
by: praveen2gupta | last post by:
Hi, Java Char Datatype supports unicode. The Unicode supports 650 Human Languages. I would like to know How to use This feature while developing the Java/J2EE/JSP web based software product.
3
by: pkumar74 | last post by:
Hi ......... I'm not good at Access but always try to make things work.....'cause i have habbit of correcting my self. I have a database , in which I have a form for purchase orders with the...
19
by: Roberto | last post by:
Can anyone recommend a PHP-based dashboard product or open source project? My employer is looking to purchase a product to collect business intelligence data like number of customer interactions...
3
by: Constantine AI | last post by:
Hi can anybody help me with this problem? I have a customer order form with a sales order line subform. The subform contains products ordered by customers, each (wooden) product can come in two...
6
by: David Wright | last post by:
Hello Folks I am using Microsoft Access 2000 I would be grateful if someone could help me with “Dlookup”. I tried various methods of writing Dlookup and various events to trigger it, none of...
15
by: jaad | last post by:
I am apologizing in advance if I am not posting this question correctly. I have had a read at the posting guide and will try to see if I can do it right this time. I have an AfterUpdate event...
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:
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
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,...
0
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...

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.