PDA

Click to See Complete Forum and Search --> : SQL for a Number


nicky
Dec 24th, 1999, 11:32 AM
How do I create SQL statement that lists all the records that selects the rightmost portion of a number in the listbox. For example, I have a few records for item number.

40000
50000
52000
55000
60000

I want to enter a number, 52000, in the textbox. This will select the righmost of 3 numbers of 52000. This will print 50000, 52000, and 55000 in the listbox. How do I do that? Thank you..

Merry Christmas to you all...

Clunietp
Dec 24th, 1999, 01:28 PM
What do you mean by "rightmost 3 numbers"? Do you mean the value above it and the value below it? Do you mean anything beginning with a 5?

Clunietp
Dec 25th, 1999, 12:02 AM
So you want anything that begins with the same first digit AND has the same last 3 characters?

Merry XMAS!

nicky
Dec 25th, 1999, 12:31 AM
Yes, Clunietp!!!

Clunietp
Dec 25th, 1999, 11:27 AM
SQL = "Select * from MyTable where MyDataField LIKE " & left(clng(text1.text), 1) & "*" & right(clng(text1.text), 3)

HTH

Tom

nicky
Dec 25th, 1999, 11:51 AM
"rightmost 3 numbers" means the last 3 places of a number I enter. Yes, I want all records that start with the number "5" or any number. For instance, the statement is

Right$(txtItemNumber.Text1, 3) = "000"

It gets the rightmost 3 places (000) of that number. If I want to enter 50000 in the textbox, it prints 50000, 52000, 55000 in the listbox. How do I create an SQL statement...? I use DAO for working with the database. Thank you for responding .... Clunietp

Have a Merry Christmas to you all!