Solved

VB6, ADO, MSDataGrid and Data Environment

Posted on 1998-12-24
1
1,297 Views
Last Modified: 2013-12-25
I used VB6, ADO and Data environment and I've the following codes in my program:

FORM_LOAD
envApplication.comCustomerList
Set grdMain.DataSource = envApplication
grdMain.DataMember = "comCustomerList"

where      env = Data Environment
  grd = MS Data Grid ver 6
  com = Data Env Command objects

IT works fine and correctly populates my datagrid with the relevant list of records from the customer table. Now I'd like to have a REFRESH button that requeries the underlying recordset and updates the datagrid.

My code looks like this:

CMDREFRESH_CLICK
envApplication.rscomCustomerList.close      'closes the recordset
envApplication.comCustomerList                  'reopens it
grdMain.DataMember = "comCustomerList"      rebind to datagrid

Many people I asked had told me this code should work. My problem is that the program crashes at the last line (grdMain.DataMember = "comCustomerList") with fatal error on MSDATGRD.OCX or sometimes MSADO15.DLL

An alternative code will be:

CMDREFRESH_CLICK
envApplication.rscomCustomerList.Requery

In this case, it'll crash right away!! Someone even send me his working program using the same codes, but I still get the same errors running it on my PC. Which brings me to suspect that the problem may not be in the "codes" but is in the system files (OCXs or DLLs) in my computer's configuration, or even a bug in the DataGrid itself. Has anyone faced similar problems?

Thanks and Merry Christmas.

0
Comment
Question by:jack208
[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
1 Comment
 

Accepted Solution

by:
resin earned 100 total points
ID: 1489251
After refresh your recordset, try set the DataSource instead of DataMember:
Sub CMDREFRESH_CLICK
    envApplication.rscomCustomerList.close 'closes the recordset
    envApplication.comCustomerList 'reopens it
    Set grdMain.DataSource = envApplication
    grdMain.Refresh  
End Sub
----------------------
The program may crash because some changes in the database make the design time values no more valid. If you just display the whole recordset of command, try ClearField, programmatically set valid values for the Grid, and then Rebind.

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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 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…

696 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