Solved

Refreshing a DataGrid from a DataEnvironment Recordset

Posted on 2000-05-17
5
531 Views
Last Modified: 2012-06-27
I have a DataEnvironment set up and working. I can load the recordset into the DataGrid. Now I want to be able to change the data in the DataGrid. The user selects a menu which changes the SQL statement controlling the recordset behind the DataGrid (The DataSource and DataMember of the DataGrid). I cannot find any way of refreshing the data in the DataGrid.

My Code for one of the menu selections:

    strQuery = "SELECT MNAME, MCO, MADDR, MSTRT, MCITY, MPROV, MCNTRY, MPO1, MPO2, " & _
        "MGROUP, MID FROM " & coLib & "DT.DTNAME Order By MNAME, MCO"
    frmLoad.Show
    frmLoad.Refresh
    deAddresses.Commands(1).CommandText = strQuery
    deAddresses.rsqryDTNAME.Close
    deAddresses.qryDTNAME
    DataGrid1.ReBind
    DataGrid1.Refresh
    Me.Refresh
    Unload frmLoad


I know the query is good, because the only difference between this SQL statement and the initial SQL statement is the Order By clause. The problem is that I cannot get the damn DataGrid to refresh with the new data. However if I select a row in the DataGrid and load it into the editor I've setup I do not get the record shown on the screen. I get the record I'm supposed to get based on the new query. Any help would be appreciated ASAP!
0
Comment
Question by:bhlang
5 Comments
 
LVL 28

Expert Comment

by:AzraSound
ID: 2817590
set the grids datasource to your new recordset

set datagrid1.datasource = newrs
0
 
LVL 9

Expert Comment

by:GivenRandy
ID: 2817595
Have you upgraded to Visual Studio Service Pack 3?  This fixed object problems like this.
0
 

Author Comment

by:bhlang
ID: 2817655
I am using VB6 SP3.

I have tried setting the DataSource. The problem is not the DataSource, it is the DataMember. When using a DataEnvironment, you set up a Connection (DataSource) and a Command (DataMember). You can have multiple Commands set up under a connection. You can have multiple Connections set up in a DataEnvironment.
To set the DataMember I use the following:

Set DataGrid1.DataMember = deAddresses.rsqryDTNAME
(The command is called qryDTNAME and the DataEnvironment creates the recordset rsqryDTNAME)

Which gives me the following:

Compile error: Wrong number of arguments or invalid property assignment


0
 
LVL 14

Accepted Solution

by:
wsh2 earned 51 total points
ID: 2817705
Set DataGrid1.DataSource = deAddresses
DataGrid1.DataMember = "qryDTNAME"

is the proper syntax.. <smile>.
0
 

Author Comment

by:bhlang
ID: 2817787
That did the trick. If I had read the VB Help files better, I would have seen this in the example for DataMember. Thank you for your prompt reply. Thank you everyone else for your assistance also.
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

803 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