Solved

DataGrid Question

Posted on 2002-03-22
6
281 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
6 Comments
 
LVL 49

Expert Comment

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

Expert Comment

by:appari
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now