We help IT Professionals succeed at work.

VB6 DBGrid Control

billy21
billy21 asked
on
Medium Priority
896 Views
Last Modified: 2010-05-18
How do I populate the VB6 version of this control with a dao 3.6 recordset?

In VB5 I had to do it a rather obscure way because it did not support DAO 3.6.

In VB5 I had to

Set the "Data Source" property to the name of the control itself.
Then
Make my DAO recordset
AND
There was a property called "Recordset" that I could use to set like this:
Set MyDBControl.Recordset = MyRS

This is the only way I have ever done it BUT in the VB6 version of this control there is no "Recordset" property.
Comment
Watch Question

Software Engineer
Commented:
Hello,

I hope I don't mix up something.
You have to use the data source control. Set the property of the grid to the name of the data source control. The data source control has the property "recordsource", aswell as databasename, etc.

regards

jendrix
TimCotteeHead of Software Services
CERTIFIED EXPERT

Commented:
If you have VB6 with service pack 4 or 5 then the intrinsic Data Control which you can place on the form has a new value for the Connect Property which is "Access 2000;" you can use this to define the recordset and set the data source property of the dbgrid to this. Alternatively and in my opinion preferably, you create the recordset in code as you have before and

Set DBGrid1.DataSource = MyDAORecordset

That should do it!

Author

Commented:
jendrix,

The problem is that the "recordsource" property doesn't exist in the vb6 version of the control.

timcoffee,

I'll see if I can get my hands on the latest SP.
Friedhelm Feller-PrzybylSoftware Engineer

Commented:
Sorry billy21,

I checked it, before answering. I checked it again now:

1. The grid does not have the property "RecordSource", but the control "data control" has!
2. Set the Grids property to the name of the "DataControl". It's the same way - as far as I remember - as with VB5.

I use SP3. Which Grid do you Use (there are a lot around)? I use DBGRID32.OCX, the one that is shipped with VB

Author

Commented:
I was a little confused but as it turns out you were 100% correct.  Thanks and sorry for the long delay in responding.