By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,495 Members | 1,076 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,495 IT Pros & Developers. It's quick & easy.

Problem deleting

P: n/a
Hi,

I'm running Access 2002 and have a problem deleting records on a
continuous form.
I thought it might be due to relationships with two other tables but
having deleted these relationships, I'm still not able to delete a
record.

The code I am using is as follows:-

yn = MsgBox("Are you sure to delete all this person's details
permanently??", vbYesNo, "Save")
If yn = vbNo Then
MsgBox ("record not deleted")
Else

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If
Can anyone see anything wrong?

Yvonne

Dec 23 '06 #1
Share this Question
Share on Google+
11 Replies


P: n/a
You don't say where you have this code, but I'm guessing you have it behind a
command button. If that's the case, I think the problem is that when you
click on the button, you've taken focus away from the record you want to
delete so there is, on a continuous form, no current record, and without a a
current record, Access doesn't know which record you want to delete! Try
placing the code in the DoubleClick event of one of your controls, say the
person's name, doubleclick that control, and see if it works.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200612/1

Dec 23 '06 #2

P: n/a

missinglinq via AccessMonster.com wrote:
You don't say where you have this code, but I'm guessing you have it behind a
command button. If that's the case, I think the problem is that when you
click on the button, you've taken focus away from the record you want to
delete so there is, on a continuous form, no current record, and without a a
current record, Access doesn't know which record you want to delete! Try
placing the code in the DoubleClick event of one of your controls, say the
person's name, doubleclick that control, and see if it works.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200612/1
Yes it's behind a command button. An adjacent button that opens up a
separate form ( frmDetails) with full details of the record works OK
and frmDetails opens up.

I tried the double-click event proceedure but that didn't work.

I checked and the continuous form allows Edits and Deletions.

I put a command button to delete the record on frmDetails but that
didn't work also.

Weird, huh?

Yvonne

Dec 23 '06 #3

P: n/a
>Yvonne wrote:
I put a command button to delete the record on frmDetails but that
didn't work also.

Weird, huh?

Yvonne
Update....

It's got to be something to do with this code becuse when I take it
out, the delete goes through OK. And a simple delete command button on
frmDetals works OK also.

yn = MsgBox("Are you sure to delete all this person's details
permanently??", vbYesNo, "Save")
If yn = vbNo Then
MsgBox ("record not deleted")
Else

Does this help?

Yvonne

Dec 23 '06 #4

P: n/a
All the testing I did was with forms that were based on queries, the only way,
really, that serious developer do forms. After much fussing about, it
occurred to me to try the code on a form directly based on a table, and voila!
It ddn't work! I don't know the ends or outs, but that appears to be the
answer. Is your form, in fact, based directly on a table? If so, do up a
simple query with the appropriate fields, then change the Record Source of
your form to this new query and try out the delete code in either the
doubleclick event or behind a button event. If this isn't the case, I don't
know what else to tell you.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200612/1

Dec 23 '06 #5

P: n/a
Our last posts crossed in the ether! I don't know what to add to my last post.
Using your code

yn = MsgBox("Are you sure to delete all this person's details permanently??",
vbYesNo, "Save")
If yn = vbNo Then
MsgBox ("record not deleted")
Else
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If

I have no problem unless the form is based directly on a table.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200612/1

Dec 23 '06 #6

P: n/a
Yvonne wrote:
It's got to be something to do with this code becuse when I take it
out, the delete goes through OK. And a simple delete command button on
frmDetals works OK also.
If I were doing this I wouldn't. I've paid $200 or so for Access which
provides me with menu options and key options (<Delete>) that delete
records perfectly time after time after time. (The default condition of
the From is to ask for verification.) Why would I want to code this
behind a button? Windows is a menu driven technology. The presence of
buttons on Access forms more often than not says, "Floundering Amateur"
or, "Obstinate Neanderthal".

If I had a friend who insisted on doing this despite my advice I would
suggest to him/her that first the delete be tested by pressing the
delete key.

If that delete (<Delete>) worked I would suggest that the inane menu
calls be replaced with:

With DoCmd
.RunCommand acCmdSelectRecord
.RunCommand acCmdDeleteRecord
End With

Dec 23 '06 #7

P: n/a

End If

I have no problem unless the form is based directly on a table.
>
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200612/1
Hi again,

I changed the data source so that it was based on the table directly
and it still didnt work. The simple delete command button created with
the wizard ( ie no yn MsgBox) works fine -whether it's based on the
table or query.

Yvonne

Dec 23 '06 #8

P: n/a

Lyle Fairfield wrote:
>. The presence of
buttons on Access forms more often than not says, "Floundering Amateur"
or, "Obstinate Neanderthal".
I guess I could be acused as being a bit of both of these so I'll
gladly take your advice and get rid of the code. Life's too short to
spend too much time trying "to guild the lily".

Many thanks for your help.

Yvonne

Dec 23 '06 #9

P: n/a
"Yvonne" <lo********@yahoo.comwrote in news:1166888682.156549.66800
@i12g2000cwa.googlegroups.com:
Lyle Fairfield wrote:
>The presence of
buttons on Access forms more often than not says, "Floundering Amateur"
or, "Obstinate Neanderthal".

I guess I could be accused as being a bit of both of these ....
There's hope for the first. Concentrate on that!

--
Lyle Fairfield
Dec 23 '06 #10

P: n/a

Persistance pays!

I kept plugging away - deleting "On Current" and "On Load" events but
no difference. Then I deleted the AutoExec macro and Lo and Behold the
problem disappeared completely!

All the AutoExec does is open the form DetectIdleTime as featured in
:- http://support.microsoft.com/?id=128814

It's a neat arrangement that closes the database when no activity takes
place over a certain period of time.
I had put this in as we have a small network and from time to time
several people use it. There was a problem with record locking as some
people were keeping it open all day and doing nothing on it. We're too
small to justify SQL and all that entails so this seemed to be the
answer to our problems.

Yvonne

Dec 23 '06 #11

P: n/a
Well, Lyle, you're certainly entitled to your opinion, but it's in direct
opposition to that of any real Access developer! If everyone relied on the
built in menus there wouldn't really be much need for this or any other
Access forum! The total reliance on the myriad of menus on Access with the
lack of customs buttons says to me "Amateur" or "Too Lazy to Make the
Database User Friendly!" Those menus are there primarily so that non-
programmers can develop simple dbs. To be honest, I pity your end users.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200612/1

Dec 23 '06 #12

This discussion thread is closed

Replies have been disabled for this discussion.