473,382 Members | 1,743 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,382 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 1400
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.
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
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...

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.