• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 291
  • Last Modified:

DataGrid Question

Hi,
I've bound a datagrid to a recordset.
The recordset is coming from a query based on search criteria?
I've successfully bound the recordset to the datagrid.

Now, I have a button that if u click it'll go to the next one row in the datagrid that matches the search criteria.
If you click another button, it'll also goto previous row matching the criteria?
I'm having a trouble implmenting this feature.
Can someone shed a light on how I can do?
I believe I need to use recordset.find to go to next bookmark?
0
StriderX
Asked:
StriderX
1 Solution
 
Ryan ChongCommented:
A recordset? using ADO or DAO? Any codes available? ..
0
 
appariCommented:
if using ADODC

for backward search
Adodc1.Recordset.Find "EmployeeID=" & Text1.Text, , adSearchBackward

for forward search

Adodc1.Recordset.Find "EmployeeID=" & Text1.Text, , adSearchForward


replace find criteria with yours.
0
 
StriderXAuthor Commented:
I am using adodb.recordset and bound it to datagrid.
After forward and backward searching, how do I set the selected index to be on the DataGrid that match the same row?

Also, I 'd appreciate if someone could answer the question of how to get the index of datagrid when user double clicks?
When I use index or some other property it always gives me the previous index before I double clicked.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Anthony PerkinsCommented:
Please maintin your open questions:

Questions Asked 14
Last 10 Grades Given A A A B A B B A  
Question Grading Record 8 Answers Graded / 8 Answers Received

Thanks,
Anthony
0
 
EgeCommented:
I think , this works like you want
but you need some controls  
1-ADODC
2-DATAGRID
3-two COMMAND BUTTON
1-TEXTBOX
GOOD LUCK
''COPY HERE

Dim rowcount As Long

Private Sub Command1_Click()
On Error Resume Next 'must
Dim j As Long
For j = 0 To rowcount - 2

DataGrid1.Row = DataGrid1.Row + 1


 If DataGrid1.Text = Text1.Text Then Exit Sub

Next
End Sub


Private Sub Command2_Click()
On Error Resume Next 'must
Dim j As Long
For j = rowcount To 0 Step -1
If DataGrid1.Row = 0 Then Exit Sub Else DataGrid1.Row = DataGrid1.Row - 1

DataGrid1.Scroll 0, DataGrid1.Row - 3
 If DataGrid1.Text = Text1.Text Then Exit Sub

Next
End Sub

Private Sub Form_Load()
On Error GoTo tolga

 
Do Until Err.Number <> 0
       
       rowcount = rowcount + 1
       DataGrid1.Row = DataGrid1.Row + 1
Loop

tolga:
For j = rowcount To 0 Step -1

If DataGrid1.Row = 0 Then Exit Sub Else DataGrid1.Row = DataGrid1.Row - 1

DataGrid1.Scroll 0, DataGrid1.Row - 3
 
 
Next
Debug.Print rowcount
DataGrid1.Row = 0
Err.Number = 0
Exit Sub
End Sub



0
 
StriderXAuthor Commented:
Thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now