devxlogo

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
See also  Why ChatGPT Is So Important Today
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist