Loading

flexgrid search using text_change event

2 posts / 0 new
Last post
Offline
Joined: 06/25/2009
flexgrid search using text_change event

i just want to ask how to clear the data from flexgrid.
im using textbox to search data from flexgrid and its almost perfect but when the data i type on textbox is not in the flexgrid the flexgrid still have all the data from the database.i want to clear the data from flexgrid once the data that i type on textbox is not in the flexgrid...can someone pls help me tnx..

here is my code::

Private Sub Text3_Change()
If Me.Text3.Text = "" Then
clear
ShowTable
Exit Sub
End If

Dim rs As New ADODB.Recordset
On Error GoTo err:
rs.Open "SELECT * FROM pharmainventory where medicine_name like '" & Me.Text3.Text & "%'", con, adOpenKeyset, adLockOptimistic
rs.MoveFirst

With MSFlexGrid1
'column width
.ColWidth(0) = 300
.ColWidth(1) = 0
.ColWidth(2) = 3000
.ColWidth(3) = 1500
.ColWidth(4) = 3000
.ColWidth(5) = 1200
.ColWidth(6) = 1800

'Header
.TextMatrix(0, 2) = "Medicine Name"
.TextMatrix(0, 3) = "Mg / Ml"
.TextMatrix(0, 4) = "Make"
.TextMatrix(0, 5) = "Quantity"
.TextMatrix(0, 6) = "Price / Quantity"

'text alignment
.ColAlignment(2) = flexAlignLeftCenter
.ColAlignment(3) = flexAlignLeftCenter
.ColAlignment(4) = flexAlignLeftCenter
.ColAlignment(5) = flexAlignLeftCenter
.ColAlignment(6) = flexAlignLeftCenter

' the data
While Not rs.EOF
.TextMatrix(.Rows - 1, 1) = rs.Fields(0)
.TextMatrix(.Rows - 1, 2) = rs.Fields(1)
.TextMatrix(.Rows - 1, 3) = rs.Fields(2)
.TextMatrix(.Rows - 1, 4) = rs.Fields(3)
.TextMatrix(.Rows - 1, 5) = rs.Fields(4)
.TextMatrix(.Rows - 1, 6) = rs.Fields(5)

rs.MoveNext

.Rows = .Rows + 1
Wend
.Rows = .Rows - 1

End With

i use the code below on a datagrid and its working fine...but on flexgrid its a no no...?????????????
With rspharmainventory
.MoveFirst
While .EOF = False
If .Fields(1) = Me.Text3.Text Then
Me.txtmedicinename.Text = .Fields(1)
Me.txtmg.Text = .Fields(2)
Me.txtmake.Text = .Fields(3)
exit sub
else
clear
MSFlexGrid1.clear ' do i need to use this????
end if
.MoveNext
Wend
End With

rs.Close
err:
End Sub

admin's picture
Offline
Joined: 11/14/2008
re: flexgrid search using text_change event

use MSFlexGrid1.Clear

Pages

Add new comment

Filtered HTML

  • You may insert videos with [video:URL]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.