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

How to Search the Range Value

134 100+
I have a table called tblPrice consist of ProductID, SupplierID, Qty and Price,
Which I use to store the pricing.

Different Supplier may quote a different price on a same product base on Qty Purchase.

At the end of the day, so I can see which Supplier quoted the lowest price, so I can purchase from that supplier.

The format of the table as below:-
[TBLPRICE]

PRODUCTID | SUPPLIERID | PUR QTY | PRICE

BT-0007 SP0001 1,000 $1.50 (from 1k onward)
BT-0007 SP0001 5,000 $1.30
BT-0007 SP0001 12,000 $1.20 (from 12k onward)

BT-0007 SP-0007 1,000 $1.56
BT-0007 SP-0007 5,000 $1.35
BT-0007 SP-0007 12,000 $1.25

In the Form, I have 2 textbox - txtProdID, txtQty, If I enter BT-0007 for ProdID and 7000 for Qty
it will show the result like this : -, regardless whether in report or form.


BT-0007 SP0001 $1.30
BT-0007 SP-0007 $1.35

So I can see & compare the lowst price.
I have tried using query, it didn;t work, Any Solution ?
Jan 1 '07 #1
3 1567
NeoPa
32,556 Expert Mod 16PB
Can you explain how this is different from the question in (How to look up for the correct price base on qty)?
Maybe I'm missing something obvious (other than there is more info posted here :) of course).
Jan 1 '07 #2
jamesnkk
134 100+
Can you explain how this is different from the question in (How to look up for the correct price base on qty)?
Maybe I'm missing something obvious (other than there is more info posted here :) of course).
Thanks, It sound similar to the previous question, which able to search for the right currency base on the qty. This question was to display the entire row, this mean to display along with the supplier name, price, the table could repeat the same product with many different supplier quoting the same qty, but the price maybe different, therefore I need to search for the lowest price.
Jan 1 '07 #3
NeoPa
32,556 Expert Mod 16PB
I'm getting so frustrated to be wasting so much time on simple communication.
I'm sorry, but the only sense I could get from all that was that you want a whole record rather than a single value.
Why do you miss out words and letters and such like from an explanation? Do you want to make it hard to understand? Can you understand it if you reread it?
Please ignore this tirade if you are not a native English speaker - Then it would be understandable and a restriction I'm happy to work within.
Otherwise, I will simply ignore a post in future if it is not clear on the first couple of readings.

I went back to the first post and re-read it in detail and I think I've got what you're asking now.
You need a ComboBox to show the results and the RowSource of the ComboBox (We will call it cboResults) should be set like :
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtProdID_AfterUpdate()
  2.     Call ComboSource
  3. End Sub
  4.  
  5. Private Sub txtQty_AfterUpdate()
  6.     Call ComboSource
  7. End Sub
  8.  
  9. Private Sub ComboSource()
  10.     Dim strSQL As String, strPrice As String
  11.  
  12.     If Nz(txtProdID, "") = "" Or Nz(txtQty, 0) = 0 Then
  13.         strSQL = ""
  14.     Else
  15.         strPrice = "CCur(Mid(Max(" & _
  16.                    "Format([Pur Qty],'0000000000') & " & _
  17.                    "[Price]),11)) "
  18.         strSQL = "SELECT ProductID," & _
  19.                         "SupplierID," & _
  20.                         strPrice & _
  21.                      "FROM tblPrice " & _
  22.                      "WHERE ((ProductID='" & txtProdID & "')" & _
  23.                      "  AND ([Pur Qty]<=" & txtQty & ")) " & _
  24.                      "GROUP BY SupplierID"
  25.     End If
  26.     cboResults.RowSource = strSQL
  27. End Sub
Jan 1 '07 #4

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

Similar topics

5
by: Greg | last post by:
I have a page that searches a database by a repairman's name and by a date range. It pulls info by the repairman's name but pulls all info in the database regardless of the date. Below is the code...
1
by: Eric | last post by:
Hi: I have two files. I search pattern ":" from emails text file and save email contents into a database. Another search pattern " field is blank. Please try again.", vbExclamation + vbOKOnly...
6
by: zfareed | last post by:
<code> #include <iostream> #include <fstream> const int MAX_LENGTH = 10; using namespace std;
14
by: Simon Gare | last post by:
Hi, have a search.asp page with results.asp page drawing data from an SQL db, problem is the user has to type the whole field value into the search box to retrieve the value on results.asp, what...
0
by: mwalsh62 | last post by:
Greetings all! My first post here, and my mind is pudding at this point (any flavor you like)! I have been searching for days, and still can't figure out the proper syntax that I require. This...
1
by: silentbuddha | last post by:
Hi, I am currently having some difficulties with this sunroutine that I created. My 2 dimensional array is empty. - This code is within my UserForm1 - this sub is suppose to first select the...
2
by: Bart Kastermans | last post by:
Summary: can't verify big O claim, how to properly time this? On Jun 15, 2:34 pm, "Terry Reedy" <tjre...@udel.eduwrote: Thanks for the idea. I would expect the separation to lead to somewhat...
2
by: jotr | last post by:
I recently received help writing a search macro for excel, but now I am trying to change it up to use it in another spreadsheet, and I am having some troubles. I need it to search two cells one has...
12
by: jotr | last post by:
I posted this question already (Admin Edit Need help with my search macro for excel), but I made a mistake in writing the question, so I posted a reply and I am afraid that at a glance it may be...
6
Kelicula
by: Kelicula | last post by:
Why?: One commonly used algorithm is the binary search. If you don't already know it, you should read on. Very helpful. Saves much CPU. Reduces computations exponentially. When searching...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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
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...

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.