VBA to delete records in subform

G

Guest

Hello,

I have a main form(frmMain) and a subform in it (subfrmCustomers) which has
data from a Table

There is a button in the main form(frmMain) which is do delete one or many
highlighted rows in the subfrmCustomers. The problem is I don't know how to
code to achieve this. I can figure the code for one selected row to be
deleted but really don't know how to delete for many selected rows of
records. That is where I need help on.

I tried:

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

But it doesnt work, I guess becuase after you highlight lots of rows & then
go to click the button on the Main form the Highlighted rows loses its focus.

Any help would be greatly appreciated.

Thank you,
Jeff
 
M

Mark A. Sam

Jeff,

This may help you. Not knowing your intentions, or your application I can't
be much more helpful, but this code placed on a button's CLick Event on a
mainform will select the current row and the two below it and delete the
three records.

Me.SelHeight = 3
DoCmd.RunCommand acCmdDelete

Maybe you can use this to work for you. If you manually select the records
on the subform, isn't it just as easy to press the Del key?

God Bless,

Mark A. Sam
 
G

Guest

Thnx for the reply but not what I am looking for.

read above, if the records are Already selected in subform to delete those
records that were selected.

Thnx,
Jeff
 
M

Mark A. Sam

I did read it which is why I suggested the Del key ;)

This is solved if there is a property which specifies how may records are
selected. Then that could replace the value for the rowcount (which in this
case it three). I'll check into it and see if what can be done.

God Bless,

Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Button to delete record on datasheet subform 5
Error 2237 8
vba coding 4
new form 1
Copying Records 12
"Delete Record" command button woes 4
acEditMenu help 1
delete subform record 2

Top