1 Replies - 2338 Views - Last Post: 12 April 2012 - 07:41 AM Rate Topic: -----

#1 Dcjoshi   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 05-April 12

want to delete data from two tables from a single button

Posted 11 April 2012 - 07:50 PM

Sir I make an application in which I want to delete data from two tables with single Delete button.
The following coding deletes data from a single table newuser:
Private Sub Cmddelete_Click()
With rs
.Delete
.MoveNext
If .EOF Then
.MoveLast
End If
End With
end sub

Private Sub Form_Load()
cn.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source =" & App.Path & "\library system.mdb;Persist Security Info=False")
rs.Open "select * from newuser", cn, adOpenDynamic, adLockOptimistic
end sub

plz sir tell me how i delete data from both tables and both tables contain some similar data in backend

with regards



Mod edit:
Fixed the code tags. Next time please do:

:code:

This post has been edited by Atli: 11 April 2012 - 08:01 PM


Is This A Good Question/Topic? 0
  • +

Replies To: want to delete data from two tables from a single button

#2 Ionut   User is offline

  • D.I.C Lover
  • member icon

Reputation: 386
  • View blog
  • Posts: 1,057
  • Joined: 17-July 10

Re: want to delete data from two tables from a single button

Posted 12 April 2012 - 07:41 AM

You could use delete statements for your tables as:
sub WhateverSubClick()

cn.Execute "delete from table1"
cn.Execute "delete from table2"

end sub



You could add where clause if you want
sub WhateverSubClick()

cn.Execute "delete from table1 where someColumn = " + aValue 'although is correct, is not recommanded. Use parameters instead
cn.Execute "delete from table2 where otherColumn =" + anotherValue

end sub


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1