Link to home
Start Free TrialLog in
Avatar of JohnClayson2
JohnClayson2

asked on

DataGrid problem with lookup fields

I am having problems refreshing the contents of a bound data grid when I add a new row.  The problem only lies in fields which are from “lookup” tables.

I am using a datagrid (datagrid control 6.0 (OLEDB)) in VB6 linked to a command object of a DataEnvironment (DE) (which linked to a SQL Server 7 database).

I am using ADO (2.1) to access the data in the database

There are several fields in the main table in the database which store numeric values which link to fields in lookup tables which have text descriptions in them.

I set up a command object under the DE which shows the numeric fields from the main database table and the equivalent text descriptions from the lookups.

I drop the datagrid on the form and set the datasource and datamember at design time – when I load the form everything is shows OK in the datagrid.  I then have a command button which loads a data input form to add a new record to the grid.  Having added the data I do a recordset.update and return to the form with the datagrid on it – all fields have updated OK except those which show the values from the lookup tables.

If I close down the app and then run it again, the datagrid shows all the new values including the lookup fields

Any ideas how to solve this ?
ASKER CERTIFIED SOLUTION
Avatar of vettranger
vettranger

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JohnClayson2
JohnClayson2

ASKER

The thing that solved the problem was the setting of the data source for the grid to the command's recordset i.e

mydatagrid.datamember=""
mydatagrid.datasource=myDE.rsmycmd

When I later do a rsmycmd.requery then everything updates OK in the grid.
Very good, and thanks for the follow up. I try to keep up with exactly what methods solve these DE issues.
This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.

This is the Community Support link, if help is needed, along with the link to All Topics since many new ones were recently added.

https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
https://www.experts-exchange.com/jsp/zonesAll.jsp
 
Thanks,
Moondancer
Moderator @ Experts Exchange