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

How to look up for the correct price base on qty

134 100+
I have a table which stored the part nos, qty, price. The Part Nos is repeated cos the qty and price is different.It base on qty volume.

PART NO QTY PRICE
A-0123 1000 1.5
A-0123 7000 1.0

I want to retrieve the correct price base on qty input by user. If user input Part Nos = A-0123, and Qty= 6000, then I should retrieve the price at 1.5. If user enter 10,000 then I should retrieve 1.0.

I have no idea, this is tough for me, Please help
Dec 30 '06 #1
3 1397
NeoPa
32,556 Expert Mod 16PB
It would certainly help if the question made more sense... or if the Table name were provided... or you told us where you were trying to use the info.
In the absence of all that I will just have to guess.
I'm assuming you are entering the quantity on a form in the text box txtQty and you want to populate the label lblPrice.
The table used is tblPrice and the product code is displayed on the form in txtProduct.
I'm also assuming that the record layout is as shown ([Part No],[Qty] & [Price]).
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtQty_AfterUpdate()
  2.     Dim curPrice As Currency
  3.     Dim strWhere As String, strResult As String
  4.  
  5.     strResult = "Format([Qty],'0000000000') & [Price]"
  6.     strWhere = "(([Part No]='" & txtProduct & "') AND " & _
  7.                 "([Qty]<=" & txtQty & "))"
  8.     curPrice = CCur(Mid(DMax(strResult, "tblPrice", strWhere), 11))
  9.     lblPrice.Caption = Format(curPrice , "Currency")
  10. End Sub
Dec 31 '06 #2
jamesnkk
134 100+
It would certainly help if the question made more sense... or if the Table name were provided... or you told us where you were trying to use the info.
In the absence of all that I will just have to guess.
I'm assuming you are entering the quantity on a form in the text box txtQty and you want to populate the label lblPrice.
The table used is tblPrice and the product code is displayed on the form in txtProduct.
I'm also assuming that the record layout is as shown ([Part No],[Qty] & [Price]).
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtQty_AfterUpdate()
  2.     Dim curPrice As Currency
  3.     Dim strWhere As String, strResult As String
  4.  
  5.     strResult = "Format([Qty],'0000000000') & [Price]"
  6.     strWhere = "(([Part No]='" & txtProduct & "') AND " & _
  7.                 "([Qty]<=" & txtQty & "))"
  8.     curPrice = CCur(Mid(DMax(strResult, "tblPrice", strWhere), 11))
  9.     lblPrice.Caption = Format(, "Currency")
  10. End Sub

Sorry for not giving you more detail as I was too work out on the problem and forget to provide you more detail, But you have guess 100% correctly, and thank for that hard to find coding, and exactly what I want, I have tried it out, it work.

Thank You So Much and Happy New Year to You.
Dec 31 '06 #3
NeoPa
32,556 Expert Mod 16PB
You're welcome.

Happy New Year :)
Dec 31 '06 #4

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

Similar topics

9
by: John Cho | last post by:
// CHO, JOHN #include<iostream> class fracpri{ int whole; int numer; int denom;
10
by: Alf P. Steinbach | last post by:
The fifth part of my attempted Correct C++ tutorial is now available, although for now only in Word format (use free Open Office if no Word), and also, it's not yet been reviewed at all -- ...
1
by: Blake | last post by:
Below is the queries and the results I get when in psql monitor> QUERY 1: SELECT id,price FROM store ORDER by price ASC; RESULT : List from LOWEST price to HIGHEST price QUERY 2: SELECT...
17
by: homepricemaps | last post by:
hey folks, have a logic question for you. appreciate the help in advance. i am scraping 3 pieces of information from the html namely the food name , store name and price. and i am doing this...
2
by: Mike | last post by:
Hello NG, i am just learning various Design Patterns and now i am not sure, if this design is correct (Builder) or if i should use an other pattern. I have various classes (here ChildA and...
0
by: Tony K | last post by:
While performing a fill() method, the first record NEVER shows the correct price of database item. The 2nd record and every record that has a price will show the correct price. If I open the...
6
by: Generic Usenet Account | last post by:
I ran a small experiment involving RTTI and dynamic casting. Basically what I did was to cast a base class pointer to a derived type (yes, I know that is not kosher). I then performed...
0
by: Moneypenny | last post by:
Hi there, I have a Gridview control which has a dropdownlist in every row. The dropdowns are populated dynamically from a database (so the content is different in each row. There is also a select...
3
by: Ravi | last post by:
Is this the correct way to think of "base class"? The "base class" is a class from which other classes are derived. The "base class" will never be derived from another class.
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.