A1VBCode Forums

filter all values greater than given in ms access database


http://www.a1vbcode.com/vbforums/Topic31878.aspx

By blueye89 - 2/17/2013

Hi there. I need to filter all values which are greater than an given value in textbox and show them in datatable? I need quick answer please.
By zeroGiven - 2/20/2013

Dim dv As New DataView(Me.mydatabaseDataSet.Table1)

dv.RowFilter = "Column1 > Val(TextBox1.Text)"

DataGridView1.DataSource = dv




I'm going to assume that the reason for your problem is your basically asking for column1 to be greater than Val(TextBox1.Text) and that TextBox1.Text is not a number. Now wait. Let me explain what I mean.



That line is taken as a literal string



Column1 > Val(TextBox1.Text) exactly that.



What I think you're wanting to do is concatenate what is in TextBox1's .Text property to the RowFilter as such



dv.RowFilter = "Column1 > Val(" & TextBox1.Text & ")"



So in this example let's say that you entered 55 in textbox1 this would result in

dv.RowFilter = "Column1 > Val("55")" and should no longer produce an error.