Solved

DB - Refreshing data in DataGrid

Posted on 2002-03-19
8
159 Views
Last Modified: 2010-05-02
Hello,

I change a certain field in my MS-Access data-base from the program. Then I click on my "Show Query" button. It shows a new form with DataGrid (which is connected to Data-Envirement). However the data I see is old (not updated). Only if I restart the program I see the changes. How can I refresh the query (I thing I should update a command in the Data-Envirement but I don't know how).

Please check your suggestion before sending it.
Once I get a working answer, I will accept it.

Thanks in advance.
   Slava.

--------------------------

If you collect MP3 files, visit my web-page:
http://www.organizermp3.com
0
Comment
Question by:slavikn
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 18

Expert Comment

by:bobbit31
ID: 6880844
Unfortunately, the Refresh method doesn't work when the control's DataSource is a DataEnvironment. Instead, to show the updated recordset changes, first update the DataEnvironment's recordset, then rebind the DataGrid to the DataEnvironment. So, if you have a Refresh button, it's click event might look like this:

DataEnvironment1.rsCommand1.Requery
Set DataGrid1.DataSource = DataEnvironment1

Now, when you click the Refresh button, the code rebinds the DataEnvironment to the DataGrid and refills the control with the refreshed data.
0
 
LVL 15

Accepted Solution

by:
lyonst earned 100 total points
ID: 6880856
does this answer yor question ?

http://www.a1vbcode.com/vbtip.asp?ID=39

The DataGrid control is a great way to display multiple data rows in a table-like format. Unfortunately, the control is also plagued with bugs. Some have been fixed by Service Patch 3, but some haven't. For instance, if you connect the DataGrid to a DataEnvironment, then make changes to the underlying recordset and refresh the DataGrid with the Refresh method, the control still doesn't reflect the changes. Unfortunately, the Refresh method doesn't work when the control's DataSource is a DataEnvironment. Instead, to show the updated recordset changes, first update the DataEnvironment's recordset, then rebind the DataGrid to the DataEnvironment. So, if you have a Refresh button, it's click event might look like this:

DataEnvironment1.rsCommand1.Requery
Set DataGrid1.DataSource = DataEnvironment1

Now, when you click the Refresh button, the code rebinds the DataEnvironment to the DataGrid and refills the control with the refreshed data.

Cheers,

T
0
 
LVL 1

Author Comment

by:slavikn
ID: 6880911
I accepted your answer because of the link. The previous one was the same, but the link is very useful. Thanks.
0
 
LVL 15

Expert Comment

by:lyonst
ID: 6882035
Cheers,

bobbit31 - Sorry I didn't see your answer before I posted my comment. I will post some points for you since you also posted the correct answer first.

Cheers,

T.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 18

Expert Comment

by:bobbit31
ID: 6882720
hehe, ok :)
0
 
LVL 1

Author Comment

by:slavikn
ID: 6883295
Hi again,

Something strange happens... It worked in a test program, but in the real program I get the following error: "Operation is not allowed when the object is closed."  What is the problem.

Please help!!!
Thanks in advance.

    Slava,
http://www.organizermp3.com
0
 
LVL 9

Expert Comment

by:leechoonhwee
ID: 7778676
I think you closed your recordset.
0
 
LVL 1

Author Comment

by:slavikn
ID: 7785974
leechoonhwee,

I've already accepted an answer before.

Anyway, I used a different way.
ALL my data-operations are performed using DataEnviroment. I don't forget to close recordsets and to reopen them when needed.

Thanks anyway.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

759 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

21 Experts available now in Live!

Get 1:1 Help Now