Solved

DataGrid Question

Posted on 2002-03-22
6
285 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

738 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