Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

vb datagrid.row

 
   Database Help (Home) -> Visual Basic RSS
Next:  Use .fill to write to two tables  
Author Message
ugurceng

External


Since: May 10, 2004
Posts: 1



(Msg. 1) Posted: Mon May 10, 2004 1:49 pm
Post subject: vb datagrid.row
Archived from groups: microsoft>public>vb>database (more info?)

hello
I have a datagrid and I transfer the data to datagrid from database. And
then i want to find a record that is taken from text and show it in the
datagrid. So I used the "row" property of datagrid1
but there is poblem with this property. The error occurs "Run Time error
6148 - Invalid Row number"
Can anyone help me?
Do you suggest to use another property?


Private Sub CMDFindCompany_Click()
Dim conn As Connection
Dim rs As Recordset
Dim c_name As String
Dim c_control As String
Dim i As Integer
Set conn = New Connection
Set rs = New Recordset
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & App.Path &
"\siparis.mdb "
rs.Open "select * from table_company_name ", conn, adOpenStatic,
adLockOptimistic

rs.MoveFirst
c_control = LCase(Text1)

Do Until rs.EOF
c_name = LCase(Trim(rs.Fields("company_name")))

If (c_name = c_control) Then

FORM_Add_Company.DataGrid1.Row = i

rs.MoveLast
rs.MoveNext
Me.Hide

Else
rs.MoveNext
i = i + 1
If c_name <> c_control And rs.EOF Then
MsgBox c_control & " there is no company with this name..."
Me.Hide
End If
End If

 >> Stay informed about: vb datagrid.row 
Back to top
Login to vote
Earl1

External


Since: Feb 25, 2004
Posts: 28



(Msg. 2) Posted: Wed May 12, 2004 8:52 pm
Post subject: Re: vb datagrid.row [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Remember that your rowcount is zero-based and your record count is
one-based.

"ugurceng" wrote in message

 > hello
 > I have a datagrid and I transfer the data to datagrid from database. And
 > then i want to find a record that is taken from text and show it in the
 > datagrid. So I used the "row" property of datagrid1
 > but there is poblem with this property. The error occurs "Run Time error
 > 6148 - Invalid Row number"
 > Can anyone help me?
 > Do you suggest to use another property?
 >
 >
 > Private Sub CMDFindCompany_Click()
 > Dim conn As Connection
 > Dim rs As Recordset
 > Dim c_name As String
 > Dim c_control As String
 > Dim i As Integer
 > Set conn = New Connection
 > Set rs = New Recordset
 > conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & App.Path &
 > "\siparis.mdb "
 > rs.Open "select * from table_company_name ", conn, adOpenStatic,
 > adLockOptimistic
 >
 > rs.MoveFirst
 > c_control = LCase(Text1)
 >
 > Do Until rs.EOF
 > c_name = LCase(Trim(rs.Fields("company_name")))
 >
 > If (c_name = c_control) Then
 >
 > FORM_Add_Company.DataGrid1.Row = i
 >
 > rs.MoveLast
 > rs.MoveNext
 > Me.Hide
 >
 > Else
 > rs.MoveNext
 > i = i + 1
 > If c_name <> c_control And rs.EOF Then
 > MsgBox c_control & " there is no company with this name..."
 > Me.Hide
 > End If
 > End If
 >
 >

 >> Stay informed about: vb datagrid.row 
Back to top
Login to vote
Mark J. McGinty

External


Since: Aug 31, 2003
Posts: 30



(Msg. 3) Posted: Sun Aug 22, 2004 2:06 pm
Post subject: Re: vb datagrid.row [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

The row property references a position in the visible display area of the
grid.

What you need to do instead of this is:

Clone the recordset that's bound to the datagrid
Call the Find method on the clone
If the row is found, set the grid.Bookmark property to the recordset
clone's Bookmark property


Dim rsClone As ADODB.Recordset
Set rsClone = GetGridRecordset(grid)
rsClone.MoveFirst
rsClone.Find "company_name = '" & c_control & "'"
If not rsClone.EOF Then grid.Bookmark = rsClone.Bookmark


Public Function GetGridRecordset(ByRef Grid AS DataGrid) As ADODB.Recordset
Set GetGridRecordset = Nothing
If Grid Is Nothing Then Exit Function
Dim rs As ADODB.Recordset
Dim obj As Object
Set obj = Grid.DataSource
If (Grid.DataMember <> Empty) Then
Set rs = obj.DataSource
Else
Set rs = obj
End If
If (TypeOf rs Is ADODB.Recordset) Then
Set GetGridRecordset = rs
Else
Debug.Print "GetGridRecordset", "No recordset for grid ", Grid.Name
End If
Set rs = Nothing
Set obj = Nothing
End Function



-Mark



"ugurceng" wrote in message

> hello
> I have a datagrid and I transfer the data to datagrid from database. And
> then i want to find a record that is taken from text and show it in the
> datagrid. So I used the "row" property of datagrid1
> but there is poblem with this property. The error occurs "Run Time error
> 6148 - Invalid Row number"
> Can anyone help me?
> Do you suggest to use another property?
>
>
> Private Sub CMDFindCompany_Click()
> Dim conn As Connection
> Dim rs As Recordset
> Dim c_name As String
> Dim c_control As String
> Dim i As Integer
> Set conn = New Connection
> Set rs = New Recordset
> conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & App.Path &
> "\siparis.mdb "
> rs.Open "select * from table_company_name ", conn, adOpenStatic,
> adLockOptimistic
>
> rs.MoveFirst
> c_control = LCase(Text1)
>
> Do Until rs.EOF
> c_name = LCase(Trim(rs.Fields("company_name")))
>
> If (c_name = c_control) Then
>
> FORM_Add_Company.DataGrid1.Row = i
>
> rs.MoveLast
> rs.MoveNext
> Me.Hide
>
> Else
> rs.MoveNext
> i = i + 1
> If c_name <> c_control And rs.EOF Then
> MsgBox c_control & " there is no company with this name..."
> Me.Hide
> End If
> End If
>
>
 >> Stay informed about: vb datagrid.row 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
sql query returns in wrong format - Hi, Hope someone can help me with this. I have MS SQL 2000 database where i have Table "PriceList" and there a column "Pricemk" wich is data type "money". All data in this column is in form "10001,35". So why when...

arrays - is there a way to concatenate the contents of an array (looping through the array) and storing each item in a comma delimited string? Thanks!

DataReport PageBreak - Hi everyone, I would like to know how to force pagebreak in a datareport for example after 5 records printed. Thank you all

Possible Use of a Cursor - I have a complex query that I hope I can explain it well enough for everyone to understand. I have a table that contains information for work instructions. Contained in the table are "MACHINE_PROC" these are groupings of machining processes....

Scroll Bars - Is there a way to find the size of scrollbars on a system using Visual Basic 6.0? I know how to look and change them on the display properties, but I don't know how to access that information from within Visual Basic.
   Database Help (Home) -> Visual Basic All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]