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

Delete option is not working

Status
Not open for further replies.

smitavlsi

Programmer
Dec 18, 2003
6
IN
Dear Sir
I have written a program in which i want to delete a particular record from the datagrid using select the record.
I am accesing a table and showing it into a datagrid using "Recordset". then i want to delete that record which i have selected through Datagrid. But its deleting only that record which is showing on the screen.If i scrolling the datagrid and selecting the last reocrd,its not deleting.
i am sending you the code.plz help me out


dim rsDelete as new Adodb.Recordset
rsDelete.CurserLocation = adUseClient
rsDelete.open "Main_Item",db,adopendynamic,adlockoptimistic
rsDelete.Move Datagrid1.Row
if Datagrid1.RecordSelector = True Then
rsDelete.Delete adAffectCurrent
rsDelete.Update
End if


thanks and Regs
Smita
 
I may be wrong but I'm pretty sure that the datagrid row property is the visible row,i.e the first row in your grid may actually be row 10, scrolled. so if you click on the visible row it will return row 1.

I think there is a property which will tell you the first visible row. You can work out the correct row number from there.

Matt



If you can keep your head while those around you are losing theirs, you obviously haven't grasped the seriousness of the situation
 
Sir
i know that but plz tell me the solution what shud i do.
Regs
smita
 
Is the DataSource for the DataGrid set to rsDelete?

Use the DataSource which the DataGrid is bound to:

(Replace the below rsData recordset object with the name of the recordset object the grid is bound to, or the name of the Adodc data control's recordset - Adodc1.Recordset)

Set DataGrid1.DataSource = rsData

'User clicks on a certain row.
'Delete that row:
rsData.Delete

More is not needed to delete a record in the MSDataGrid.
 
Dear Sir
Still i didnt get the solution of my problem.Please tell me what should i do?i cudnt delete the last record of the table which i can see after scrolling the Datagrid
plz Help
Thakns and regs
Smita
 
Then you are going to have to post the code which you are using.
The code you posted above is NOT the exact code you are using.

In addition, you are going to have to answer my question.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top