Solved

Refreshing a DataGrid from a DataEnvironment Recordset

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now