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!

refresh DataGrid

Status
Not open for further replies.

MYRTOS

MIS
Sep 16, 2005
4
0
0
I have 4 cols in my DataGrid1
EmplCode,EmplName,OccCode,OccDescr

Please,
when I change the 'OccCode' in DataGrid1 the table [Employees] is updated but the the next col 'OccDescr' that comes from the joined table [Occupations] is not refreshed right away!!!

Next is the way The Datagrid1 is initialized.

Private Sub Form_Load()
Set rsE = New ADODB.Recordset
rsE.Open "sELECT e.EmplCode,e.EmplName,e.OccCode, o.descr AS OccDescr " _
& "FROM [Employees] e " _
& "left outer JOIN [Occupations] o ON o.CODE = e.OCCUP order by e.EMPLCODE " _
, cnWG, adOpenStatic, adLockOptimistic
Set DataGrid1.DataSource = rsE1
' End With
End Sub


 
HI MyRTOS
Datagrids are generally easy to handle. Most people seem to think you should code most of your vb objects from scratch but i say why re-invent the wheel?
Set your datagrid's source to pick from an SQL command located in your data environment. At an event like column change or edit refresh the source of the adodc from which you datagrid picks it's values and everything will change.
Regards
 
Hello Tolambo.

I've used Adodc also refreshing, rebinding etc in many events of the controls.
My assumption is that if I update foreign key column of datagrid then the column that shows a corresponding information of the key-table cannot be displayed (or with problems)

As the already mentioned example:
Private Sub Form_Load()
Set rsE = New ADODB.Recordset
rsE.Open "sELECT e.EmplCode,e.EmplName,e.OccCode, o.descr AS OccDescr " _
& "FROM [Employees] e " _
& "left outer JOIN [Occupations] o ON o.CODE = e.OCCUP order by e.EMPLCODE " _
, cnWG, adOpenStatic, adLockOptimistic
Set DataGrid1.DataSource = rsE1
' End With
End Sub
 
Hi Myrtos
Lets us understand this:
1 - Your OccCode is updated nicely right?
2 - Your Occdescr does not update immediately right?

What this tells me is that you need to insert the SQL code which populates your Occdescr (source) column to a timer.
Set the Timer interval to 2000 milliseconds or less.
This way the timer permanently repopulates your Occdescr column.
Solved?
The price you pay for this is a slower app as the code permanently checks to repopulate Occdescr every 2 seconds or less.
Hope that helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top