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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to clear a datagrid

Status
Not open for further replies.

newprogamer

Programmer
Sep 22, 2004
107
US
Hello,

How do I clear a datagrid. It gets the data from an access database using a recordset, then displays it in the datagrid. Any ideas?
 
If the DataSource is a recordset then clearing the grid is equivalent to deleting everything in the recordset. Is that really what you want to do?
 
Yes please. I want to clear the datagrid when the user clicks the clear command button and then allow them to search again. Actually the data comes from the datasource. Here is some of the code.

'**********
With Adodc1
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strPath & ";"
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.CommandType = adCmdText
.RecordSource = strSelect
.Refresh
End With

Set DataGrid1.DataSource = Adodc1

DataGrid1.Columns("Quote").Alignment = dbgLeft
DataGrid1.Columns("Manufacturer").Alignment = dbgLeft
DataGrid1.Columns("type").Alignment = dbgLeft
 
Thanks Golom, below is the code I added to clear the data from the grid.


Set DataGrid1.DataSource = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top