Error in DBGrid

Error in DBGrid

The documentation for the DBGrid in VB4’s Professional and EnterpriseEditions states that the control’s Text and Value properties allow youto read or set the contents of a cell. This would seem to indicate thatyou could use these properties to update a field in a record set to whichthe grid is bound. Unfortunately, that is not the case. The following codegenerates runtime error 438: “Object doesn’t support this propertyor method:”

 ' This doesn't work:DBGrid.Columns(0).Text = "Hello, world."' Neither does this:DBGrid.Columns(0).Value = "This is a test"

The workaround is to update the data control’s record set directly.The change will be reflected automatically in the bound grid:

 datCtl.Recordset.EditdatCtl.Recordset.Fields(0) = "This is a test"datCtl.Recordset.Update


Share the Post: