Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid Adding Blank Line Automatically

Status
Not open for further replies.

adamcbest

MIS
Feb 6, 2006
38
US
We have a datagrid on a form that is bound to a physical ADODC control at run time. This works fine except for one issue. When the form loads, and there is are no records in the grid, the datagrid is automatically being populated with a blank line. If you try to click out of that record and/or close the form without entering anyhting, it says "empty row cannot be inserted. Row must have at least one column value set"

Is there anyway to keep these blank records from popping up until you start typing in a new record?
 
If the user is not allowed to add a record in the grid, then use DataGrid1.AllowAddnew=false

Otherwise, check to see if your code is trying to update the recordset/DataGrid when no new records are present.

There are three properties available to check the state:

?rs.EditMode=adEditAdd (or Data1.Recordset.EditMode=adEditAdd)
'To see if the recordset (and grid) has gone into the AddNew mode.

?DataGrid1.AddNewMode=dbgNoAddNew
'To see if data the grid has gone into the AddNew mode.

?DataGrid1.EditActive
'To see if data has been entered into the grid.

Call rs.CancelUpdate and set DataGrid1.EditActive=false if needed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top