How to Delete a Found Record in a Form

H

HumanJHawkins

Hi all,

I wanted to delete a record using the following:
Me.FieldToSearch.SetFocus
DoCmd.FindRecord Me.ThingToDelete
DoCmd.RunCommand acCmdDeleteRecord

But, while the "FindRecord" command does find the record, the next line
does not operate on the record that was found... It will either do
nothing, or it will delete whatever record happened to be selected
before the FindRecord command ran.

Can anyone tell me what I am doing wrong?

Thanks!
 
S

steve

Sorry, records aren't stored in forms.

There only stored in tables and queries.

HTH

Steve
 
H

HumanJHawkins

True, but forms often do have underlying recordsets that one can
access, modify, etc. via the form. For example, I can add a record
quite successfully with:

DoCmd.GoToRecord , , acNewRec
Me.FieldToAddTo = Me.DataToAdd

But doing the opposite is not proving so easy. Are you saying that I am
doing the "FindRecord" in the recordset, but am doing the attempt to
delete via the form, and that this is why it is failing?

There may be truth in that, but I don't think it is 100% right, because
simply doing the "FindRecord" part does cause the focus in the form to
shift to the data I am looking for. However, it does not change the
selected record (which appears to be what the delete command operates
off of)
 

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

Top