Click to See Complete Forum and Search --> : Automatically going to a record in flexgrid
jarnold
Sep 20th, 1999, 07:25 PM
I want a flexgrid to go to a certain record when a name is entered into a text box and a button is pushed. The idea is to allow users to be able to get close with "smi" and be able to look at the grid and see "smith" and so on. Thanks for your help and any sample code is appreciated.
Datacontrol = data1
textbox = txttargetname
button = cmdsearch
Aaron Young
Sep 23rd, 1999, 02:39 AM
Here's an example that searches as you type, it assumes the entries in the grid for the Search Field are Sorted, to change the Search Field, set SEARCH_FIELD to the column Number..
Private Const SEARCH_FIELD = 1
Private Sub txtTargetName_Change()
Dim I As Integer
With MSFlexGrid1
.FocusRect = flexFocusNone
.SelectionMode = flexSelectionFree
For I = 1 To .Rows - 1
If Left(LCase(.TextMatrix(I, SEARCH_FIELD)), Len(txtTargetName)) = LCase(txtTargetName) Then
.Row = I
.Col = SEARCH_FIELD
Exit For
End If
Next
End With
End Sub
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net
jarnold
Sep 29th, 1999, 05:57 AM
I may not have been clear with my desired results. When typing letters into a text box, I want the flexgrid to follow along with the recordeset in the grid being highlighted as each additional letter is added to the text box.
The code asbove didnt't seem to work. Any and all help is appreciated
TonyJJ
Oct 8th, 1999, 10:31 AM
try this code to display records in a flexgrid as you type in a text box
Private Sub txt_BySName_Change()
Dim vs_Part As String
Dim vi_len As Integer
vi_len = Len(txt_BySName.Text)
vs_Part = txt_BySName.Text
dat_Search.RecordSource = "SELECT [Memb_Code] as Code, [C_Name] as Given, [S_Name] as Surname, [Tel_H] as [Home Telephone] FROM Members WHERE left([S_Name]," & vi_len & ") = '" & vs_Part & "' ORDER BY [S_Name]"
dat_Search.Refresh
End Sub
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.