Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DATAGRID REFRESH VALUE

Status
Not open for further replies.

Judai

Programmer
Oct 23, 2002
42
0
0
IL
Hello,

I run a datagrid on a form, perform the following actions:

Code:
Private Sub Command1_Click()
With DataGrid
    .ReBind
    .Refresh
End With
MsgBox "Datagrid value is   " & DataGrid
End Sub

What I get is the first item on the first column of the datagrid (column(0)),
Which is the date from a database table.

What happening here? what the cause to this?
How do I refresh the datagrid's content?
 
Try this:

Also read carefully the FAQ referred below
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
I'm not sure what your data source is but try this

Private Sub GridRefresh()
mydata.rsDesiredDisplay.Requery 'refresh the recordset
With DataGrid1
.ClearFields 'dump the existing data
Set .DataSource = mydata 'this is a data environment
.DataMember = "DesiredDisplay" 'command from data env
End With
End Sub

If you are not using a data environment this code may not apply to you. But I think the basic clearfields, Set datasource, assign datamember will work for you.
If it doesn't let me know, I have a program using this and I thought it was working.

In case you are wondering the datamember would not allow the use of "Set." I thought that was a little weird.
 
Assumming you had data showing before and have performed some action causing it to not show the data correctly now, then try refreshing the data in the DataGrid, bound to a recordset or Data Control, and not the grid itself:

DataGrid1.HoldFields
rsADO.Requery (or Resync)
'or Adodc.Recordset.Requery
'or 'or Adodc.Refresh
DataGrid1.Rebind


You do not need to clear the grid first, or rebind it.
It is already bound to a recordset, so when the recordset changes, the grid will change.
The HoldFields and Rebind methods are only needed if you have changed the header names or formated columns. [/b][/i][/u][sub]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top