Solved

VB6, ADO, MSDataGrid and Data Environment

Posted on 1998-12-24
1
1,296 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
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

733 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