?
Solved

DB - Refreshing data in DataGrid

Posted on 2002-03-19
8
Medium Priority
?
168 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 400 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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
 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

741 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