Solved

DataGrid Question

Posted on 2002-03-22
6
286 Views
Last Modified: 2010-05-02
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
Comment
Question by:StriderX
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 52

Expert Comment

by:Ryan Chong
ID: 6888083
A recordset? using ADO or DAO? Any codes available? ..
0
 
LVL 39

Expert Comment

by:appari
ID: 6888087
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
 

Author Comment

by:StriderX
ID: 6889450
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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 6891876
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
 
LVL 1

Accepted Solution

by:
Ege earned 200 total points
ID: 6898686
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
 

Author Comment

by:StriderX
ID: 6910754
Thanks
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question