LOCALIZAR EM UMA FLEXGRID

RICOCARDOZO 02/03/2005 10:00:36
#70690
Estou usando o seguinte código em um evento change para q a medida q vou digitando no text ele vai selecionado no flex ,está funcionando bem só queria acertar um detalhe:

se na grade tem a palavra pgto de luz e eu digito pgto de luz da empresa, ele continua a selecionar na grade e se eu teclo enter ele envia para o text.
Ou seja se a palavra não se encontra na grade ele não deveria selecionar.

se alguém poder me dar uma luz neste código ou que tenha outro para trocarmos idéias agradeço..

segue o código:

Private Sub SELECIONAHISTORICO()
Dim i As Integer, sProcura As String, sGrid As String
Dim bComp As Byte

sProcura = UCase(TEXTHISTORICO.Text)
bComp = Len(sProcura)

For i = 0 To GRADE2.Rows - 1
sGrid = UCase(Trim(GRADE2.TextMatrix(i, 1)))
If sProcura = Left$(sGrid, bComp) Then
GRADE2.Row = i
GRADE2.Col = 0
GRADE2.ColSel = GRADE2.Cols - 1
GRADE2.TopRow = GRADE2.Row
Exit For
End If
Next
End Sub
TROVAM 02/03/2005 15:42:52
#70772
Resposta escolhida
ve te ajuda mano...

Private Sub TextoaBuscar_Change()
On Error Resume Next
If cboBusqueda.Text <> "" Then
FlexResultado.Rows = 1
If FlexResultado.Rows = 1 Then
FlexResultado.TextMatrix(0, 0) = "Artist"
FlexResultado.TextMatrix(0, 1) = "CD Name"
FlexResultado.TextMatrix(0, 2) = "Price"
FlexResultado.TextMatrix(0, 3) = "Reference"
End If

Select Case cboBusqueda.Text
Case "Artist"
AutoComplete TextoaBuscar, FlexResultado, DB, "ListaCDs", "Artista"
Case "CD Name"
AutoComplete TextoaBuscar, FlexResultado, DB, "ListaCDs", "Disco"
Case Else
End Select
Else
TextoaBuscar = ""
cboBusqueda.ListIndex = 0
End If
End Sub

Public Function AutoComplete(sTextbox As TextBox, sFlexGrid As MSFlexGrid, sDB As Database, sTable As String, sField As String) As Boolean
On Error Resume Next
Dim sCounter As Integer
Dim OldLen As Integer
Dim sTemp As Recordset

'Set AutoComplete function to FALSE
'Seta AutoComplete como Falso
AutoComplete = False
If Not sTextbox.Text = "" And IsDelOrBack = False Then

OldLen = Len(sTextbox.Text)
Set sTemp = sDB.OpenRecordset("SELECT * FROM " & sTable & " WHERE " & sField & " LIKE '" & sTextbox.Text & "*'", dbOpenDynaset)

If Not sTemp.RecordCount = 0 Then
If sTemp.EOF = True And sTemp.BOF = True Then
MsgBox "Not Matching Records", vbInformation, "Error"
Else
sTemp.MoveFirst
sFlexGrid.Clear
sFlexGrid.FormatString = "Artist | CD Name | Price | Reference"
Do While Not sTemp.EOF
sFlexGrid.AddItem sTemp.Fields(1).Value
sFlexGrid.TextMatrix(sFlexGrid.Rows - 1, 1) = sTemp.Fields(2).Value
sFlexGrid.TextMatrix(sFlexGrid.Rows - 1, 2) = sTemp.Fields(5).Value
sFlexGrid.TextMatrix(sFlexGrid.Rows - 1, 3) = sTemp.Fields(4).Value
sTemp.MoveNext
Loop
End If
If sTextbox.SelText = "" Then
sTextbox.SelStart = OldLen
Else
sTextbox.SelStart = InStr(sTextbox.Text, sTextbox.SelText)
End If
sTextbox.SelLength = Len(sTextbox.Text)
AutoComplete = True
Else
sFlexGrid.Clear
End If
End If
End Function

até mais...
Tópico encerrado , respostas não são mais permitidas