Solved

Refreshing a DataGrid from a DataEnvironment Recordset

Posted on 2000-05-17
5
532 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

809 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