?
Solved

VB6, ADO, MSDataGrid and Data Environment

Posted on 1998-12-24
1
Medium Priority
?
1,299 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 200 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

Industry Leaders: 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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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.
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

777 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