ms access - How to Delete a record in a subform when you click a button -
i'm getting run time error 3131 syntax error in from clause. can tell me have done wrong?
dim strsql if not (me.planttransactionquery.form.recordset.eof , me.planttransactionquery.form.recordset.bof) if msgbox("are sure want delete", vbyesno) = vbyes strsql = "delete * planttransactionquery" & _ "where transactionid=" & me![transactionid] & me.planttransactionquery.form.recordset.fields("transactionid") currentdb.execute strsql me.planttransactionquery.form.requery end if end if end sub
i don't recommend using sql statements delete records unless there no other option.
can put button on subform itself? think subforms, except datasheet views, allow have buttons on them. run normal code delete record.
docmd.runcommand accmddeleterecord edit1: since using datasheet view have 2 options.
1) datasheet view provides right-click menu delete records if go far left row.
2) other option create public function on subform runs code listed above , call main form when user clicks button on main form.
Comments
Post a Comment