[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

DB - Refreshing data in DataGrid

Posted on 2002-03-19
8
Medium Priority
?
170 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 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…
Suggested Courses

834 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