Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Refreshing a DataGrid from a DataEnvironment Recordset

Posted on 2000-05-17
5
Medium Priority
?
566 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 204 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

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.

Question has a verified solution.

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

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

783 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