3 Replies - 752 Views - Last Post: 22 November 2012 - 11:24 AM Rate Topic: -----

#1 levin  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 24
  • Joined: 08-February 11

how display in flexgrid all data in a datafield that are less than 10?

Posted 21 November 2012 - 08:23 PM

Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
    conn.Open "asois"
        rs.Open "Select StockName,Brand,Quantity from stock where Quantity <'" & "10" & "'", conn, 3, 3
                
     Set grid1.Recordset = rs
Set rs = Nothing
Set conn = Nothing



at the datafield Quantity. i want to display only those less that 10 values.my codes doesnt really work..

Attached image(s)

  • Attached Image


Is This A Good Question/Topic? 0
  • +

Replies To: how display in flexgrid all data in a datafield that are less than 10?

#2 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: how display in flexgrid all data in a datafield that are less than 10?

Posted 21 November 2012 - 11:50 PM

"Doesn't really work" doesn't tell us anything. Can't help you, sorry.

This post has been edited by BobRodes: 21 November 2012 - 11:50 PM

Was This Post Helpful? 0
  • +
  • -

#3 levin  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 24
  • Joined: 08-February 11

Re: how display in flexgrid all data in a datafield that are less than 10?

Posted 22 November 2012 - 01:07 AM

View PostBobRodes, on 21 November 2012 - 11:50 PM, said:

"Doesn't really work" doesn't tell us anything. Can't help you, sorry.




i meant.. when i use
rs.Open "Select StockName,Brand,Quantity from stock where Quantity='" & "10" & "'", conn, 3, 3

the datafield Quantity will only display all with 10 values.i also tried
rs.Open "Select StockName,Brand,Quantity from stock where Quantity<'" & "10" & "'", conn, 3, 3

but it only display all that has 0 value.what i'm trying to make is to display all values that are less than 10 or equal to 0.i also tried filtering but same thing will just display.
Was This Post Helpful? 0
  • +
  • -

#4 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: how display in flexgrid all data in a datafield that are less than 10?

Posted 22 November 2012 - 11:24 AM

Oh, ok. I assume that you have no values that are less than 0. You need WHERE Quantity <= 10.

You have to be careful with numbers, whether you put them in single quotes or not in SQL. If you do, your greater than and less than use text sorting. Here's an example. Let's say you have three numbers: 31, 279, and 8. If you sort them numerically, the order is 8, 31, 279. If you sort them as text, the order is 279, 31, 8, because it sorts from left to right as if alphabetically.

So, if you have the numbers 0, 3, 4, 9, 10, and 12, they would sort 0, 10, 12, 3, 4, 9. In this case, numbers less than 10 are the ones that are left of 10 in the sort order, which would be 0.

So, try removing the quotes. If your field type is a text type, then post back and I'll show you something else to deal with that. And of course, use <= because you want values that are less than or equal to 10.
Was This Post Helpful? 2
  • +
  • -

Page 1 of 1