Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

DB - Refreshing data in DataGrid

Posted on 2002-03-19
8
Medium Priority
?
169 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

618 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