Solved

VB6, ADO, MSDataGrid and Data Environment

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

762 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

20 Experts available now in Live!

Get 1:1 Help Now