Updating datagrid with requery, datagrid goes to top 
Author Message
 Updating datagrid with requery, datagrid goes to top

Dennis

Before requery, capture the book mark of the row in SomeBookMark  and then
after requery

DataGrid.FirstRow=SomeBookMark

Sukesh


Quote:
> Hi,

> For refreshing my data in the datagrid, I use the requery-property.
> When I do this, I set the absoluteposition of the ado recordset back to
the
> absoluteposition it was before the requery.
> When the datagrid is scrollable. The grid doesn't comes back to the state
it
> has before the requery.

> I think I must use the firstrow-property. (Thisone indicates or sets the
> first visible row)
> But when I want to set the firstrow-property, it goes wrong.

> How do I use this property?

> Greetz,

> Dennis



Fri, 15 Apr 2005 21:52:48 GMT  
 Updating datagrid with requery, datagrid goes to top
Hello !!

Try this !

Dim rec As New ADODB.Recordset

Private Sub Form_Initialize()
   Dim SQL As String

   ' nur Rezepte anzeigen, die nicht als versteckt markiert sind (Hide =
false)
   'SQL = "SELECT RNr, RBez, RClass, KdCode FROM tabRezepte WHERE
(Hide=false) ORDER BY RNr DESC"
   ' alle Rezepte werden ausgewaehlt, (Hide = false)-Auswahl wird erst bei
Filter getroffen
   SQL = "SELECT RNr, RBez, RClass, KdCode, Hide FROM tabRezepte ORDER BY
RNr DESC"

   With rec
      Set .ActiveConnection = conDBVSG
      .LockType = adLockOptimistic
      .CursorType = adOpenKeyset
      .CursorLocation = adUseClient
      .Source = SQL
   End With
end sub
.....
public sub .....
   Dim BookMark

   frmRezeptDaten.Show vbModal, Me        ' Formular fr RezeptDaten ?ffnen
   BookMark = rec.BookMark
   rec.Requery
   rec.BookMark = BookMark
   RezeptListe_Refresh                    ' Rezeptliste, Datagrid
aktualisieren
end sub

Private Sub RezeptListe_Refresh()

   With DataGrid1                            ' DataGrid
      '   .Refresh         ' not OK

      Set .DataSource = rec       ' It's OK
   End With
   ' Spaltenberschriften und -Breiten von Hidden-Label bernehmen
   AutoSizeGridByLabel DataGrid1, lblDataGrid, , False
   txtAnzRec.Text = rec.RecordCount
End Sub

Best Regards

Harald



Quote:
> Hi,

> For refreshing my data in the datagrid, I use the requery-property.
> When I do this, I set the absoluteposition of the ado recordset back to
the
> absoluteposition it was before the requery.
> When the datagrid is scrollable. The grid doesn't comes back to the state
it
> has before the requery.

> I think I must use the firstrow-property. (Thisone indicates or sets the
> first visible row)
> But when I want to set the firstrow-property, it goes wrong.

> How do I use this property?

> Greetz,

> Dennis



Fri, 15 Apr 2005 21:30:42 GMT  
 Updating datagrid with requery, datagrid goes to top
Hi,

For refreshing my data in the datagrid, I use the requery-property.
When I do this, I set the absoluteposition of the ado recordset back to the
absoluteposition it was before the requery.
When the datagrid is scrollable. The grid doesn't comes back to the state it
has before the requery.

I think I must use the firstrow-property. (Thisone indicates or sets the
first visible row)
But when I want to set the firstrow-property, it goes wrong.

How do I use this property?

Greetz,

Dennis



Fri, 15 Apr 2005 19:31:13 GMT  
 Updating datagrid with requery, datagrid goes to top
Nop,

The grid doesn't stay on the same record. The active record becomes the
firstrow. While it isn't the firstrow but the 3th or something.
Before I requery I want to now how the datagrid (with vertical scroll-bar)
placed the recordset in the grid. (firstrow property)

Dennis



Quote:
> Hello !!

> Try this !

> Dim rec As New ADODB.Recordset

> Private Sub Form_Initialize()
>    Dim SQL As String

>    ' nur Rezepte anzeigen, die nicht als versteckt markiert sind (Hide =
> false)
>    'SQL = "SELECT RNr, RBez, RClass, KdCode FROM tabRezepte WHERE
> (Hide=false) ORDER BY RNr DESC"
>    ' alle Rezepte werden ausgewaehlt, (Hide = false)-Auswahl wird erst bei
> Filter getroffen
>    SQL = "SELECT RNr, RBez, RClass, KdCode, Hide FROM tabRezepte ORDER BY
> RNr DESC"

>    With rec
>       Set .ActiveConnection = conDBVSG
>       .LockType = adLockOptimistic
>       .CursorType = adOpenKeyset
>       .CursorLocation = adUseClient
>       .Source = SQL
>    End With
> end sub
> .....
> public sub .....
>    Dim BookMark

>    frmRezeptDaten.Show vbModal, Me        ' Formular fr RezeptDaten
?ffnen
>    BookMark = rec.BookMark
>    rec.Requery
>    rec.BookMark = BookMark
>    RezeptListe_Refresh                    ' Rezeptliste, Datagrid
> aktualisieren
> end sub

> Private Sub RezeptListe_Refresh()

>    With DataGrid1                            ' DataGrid
>       '   .Refresh         ' not OK

>       Set .DataSource = rec       ' It's OK
>    End With
>    ' Spaltenberschriften und -Breiten von Hidden-Label bernehmen
>    AutoSizeGridByLabel DataGrid1, lblDataGrid, , False
>    txtAnzRec.Text = rec.RecordCount
> End Sub

> Best Regards

> Harald



> > Hi,

> > For refreshing my data in the datagrid, I use the requery-property.
> > When I do this, I set the absoluteposition of the ado recordset back to
> the
> > absoluteposition it was before the requery.
> > When the datagrid is scrollable. The grid doesn't comes back to the
state
> it
> > has before the requery.

> > I think I must use the firstrow-property. (Thisone indicates or sets the
> > first visible row)
> > But when I want to set the firstrow-property, it goes wrong.

> > How do I use this property?

> > Greetz,

> > Dennis



Fri, 15 Apr 2005 23:15:30 GMT  
 Updating datagrid with requery, datagrid goes to top
Ok,

How do I capture?



Quote:
> Dennis

> Before requery, capture the book mark of the row in SomeBookMark  and then
> after requery

> DataGrid.FirstRow=SomeBookMark

This is where it goes wrong.
But what comes before it (before the requery)

Quote:
> Sukesh



> > Hi,

> > For refreshing my data in the datagrid, I use the requery-property.
> > When I do this, I set the absoluteposition of the ado recordset back to
> the
> > absoluteposition it was before the requery.
> > When the datagrid is scrollable. The grid doesn't comes back to the
state
> it
> > has before the requery.

> > I think I must use the firstrow-property. (Thisone indicates or sets the
> > first visible row)
> > But when I want to set the firstrow-property, it goes wrong.

> > How do I use this property?

> > Greetz,

> > Dennis



Fri, 15 Apr 2005 22:50:41 GMT  
 Updating datagrid with requery, datagrid goes to top
Ok,

How do I capture?



Quote:
> Dennis

> Before requery, capture the book mark of the row in SomeBookMark  and then
> after requery

> DataGrid.FirstRow=SomeBookMark

This is where it goes wrong.
But what comes before it (before the requery)
Quote:
> Sukesh



> > Hi,

> > For refreshing my data in the datagrid, I use the requery-property.
> > When I do this, I set the absoluteposition of the ado recordset back to
> > the
> > absoluteposition it was before the requery.
> > When the datagrid is scrollable. The grid doesn't comes back to the
> >  state it has before the requery.

> > I think I must use the firstrow-property. (Thisone indicates or sets the
> > first visible row)
> > But when I want to set the firstrow-property, it goes wrong.

> > How do I use this property?

> > Greetz,

> > Dennis



Sat, 16 Apr 2005 17:48:12 GMT  
 Updating datagrid with requery, datagrid goes to top
Dennis

Try

Dim lngNbr As Long

Before requery

lngNbr=Datagrid.FirstRow

After you run requery command

Datagrid.Scroll 0,lngNbr

Sukesh


Quote:
> Ok,

> How do I capture?



> > Dennis

> > Before requery, capture the book mark of the row in SomeBookMark  and
then
> > after requery

> > DataGrid.FirstRow=SomeBookMark

> This is where it goes wrong.
> But what comes before it (before the requery)

> > Sukesh



> > > Hi,

> > > For refreshing my data in the datagrid, I use the requery-property.
> > > When I do this, I set the absoluteposition of the ado recordset back
to
> > the
> > > absoluteposition it was before the requery.
> > > When the datagrid is scrollable. The grid doesn't comes back to the
> state
> > it
> > > has before the requery.

> > > I think I must use the firstrow-property. (Thisone indicates or sets
the
> > > first visible row)
> > > But when I want to set the firstrow-property, it goes wrong.

> > > How do I use this property?

> > > Greetz,

> > > Dennis



Sat, 16 Apr 2005 22:16:02 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Need some help with DataGrids (DataGrid-->DataGrid, DataGrid-->Dataset, DataGrid-->XML)

2. Requery hosed my Datagrid!

3. label.requery from datagrid

4. How do I requery a datagrid

5. Delete Then "Refresh/Requery" DataGrid

6. VB Form always goes to top of Zorder upon form content update

7. DATAGRID: AllowAddNew -- where did it go?

8. Datagrid column autosize, is it gone?

9. Going Nuts with DataGrid

10. DataGrid - Data is gone?

11. How do I set the Datagrid row to be same size as the datagrid window

12. Using datagrid as datasource for another datagrid

 

 
Powered by phpBB® Forum Software