Delete Record

  • Thread starter Thread starter dave
  • Start date Start date
D

dave

I want to delete the current record in a form. I have
created a command button with the wizard and selected
record operations and delete record.

When I try to delete the current record it deletes but
gives me a message box "Property not Available". I have
to click OK to finish, then the deleted record still shows
in the combo box.

Any ideas what I could have done wrong or not right?
 
Hi Dave

I have no idea what code the wizard produced for you, but it was probably
written by Noah in the Ark.

Try this:
DoCmd.RunCommand acCmdDeleteRecord
 
I want to delete the current record in a form. I have
created a command button with the wizard and selected
record operations and delete record.

When I try to delete the current record it deletes but
gives me a message box "Property not Available". I have
to click OK to finish, then the deleted record still shows
in the combo box.

Any ideas what I could have done wrong or not right?

Nope. Can't see the code, so there's no way to tellwhat might be right
or wrong!

Please copy and paste the button's Click event code. Note also that
deleting a record from a Form will not delete it from a combo box
directly - what's the Rowsource of the combo?
 
I lived in and around Auckland for two years, love your
sense of humor on the code. Here is the code generated by
Noah's wizard:

Private Sub DeleteThis_Click()
On Error GOTO Err-DeleteThis_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Exit_DeleteThis_Click:
Exit Sub

Err_DeleteThis_Click:
MsgBox err.Description
Resume Exit_DeleteThis_Click
End Sub

The RecordSource is a table "tblStorageItems"

I guess I just assumed that anytime someone used the
wizard it generated the same code so everyone knew the
code generated. I apologize for not submitting it
previously. I can't find in any of my several books, or
the help menu, anything about the DoMenuItem, the
acFormBar, the acEditMenu, the acMenuVer70, etc. Is there
a good reference that shows all the posssible commands and
properties, etc that are available in Access 2002?

Thanks again Graham.

-----Original Message-----
Hi Dave

I have no idea what code the wizard produced for you, but it was probably
written by Noah in the Ark.

Try this:
DoCmd.RunCommand acCmdDeleteRecord

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

I want to delete the current record in a form. I have
created a command button with the wizard and selected
record operations and delete record.

When I try to delete the current record it deletes but
gives me a message box "Property not Available". I have
to click OK to finish, then the deleted record still shows
in the combo box.

Any ideas what I could have done wrong or not right?


.
 
The rowSource is:
SELECT tblStorageItems.StorageNumber,
tblStorageItems.StorageDesc;
The bound Column is 0
The source type is table/query
The record key is storageNumber which is column 0 and the
column I use to retrieve the record.
-----Original Message-----
I lived in and around Auckland for two years, love your
sense of humor on the code. Here is the code generated by
Noah's wizard:

Private Sub DeleteThis_Click()
On Error GOTO Err-DeleteThis_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Exit_DeleteThis_Click:
Exit Sub

Err_DeleteThis_Click:
MsgBox err.Description
Resume Exit_DeleteThis_Click
End Sub

The RecordSource is a table "tblStorageItems"

I guess I just assumed that anytime someone used the
wizard it generated the same code so everyone knew the
code generated. I apologize for not submitting it
previously. I can't find in any of my several books, or
the help menu, anything about the DoMenuItem, the
acFormBar, the acEditMenu, the acMenuVer70, etc. Is there
a good reference that shows all the posssible commands and
properties, etc that are available in Access 2002?

Thanks again Graham.

-----Original Message-----
Hi Dave

I have no idea what code the wizard produced for you,
but
it was probably
written by Noah in the Ark.

Try this:
DoCmd.RunCommand acCmdDeleteRecord

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

I want to delete the current record in a form. I have
created a command button with the wizard and selected
record operations and delete record.

When I try to delete the current record it deletes but
gives me a message box "Property not Available". I have
to click OK to finish, then the deleted record still shows
in the combo box.

Any ideas what I could have done wrong or not right?


.
.
 
-----Original Message-----
I lived in and around Auckland for two years, love your
sense of humor on the code. Here is the code generated by
Noah's wizard:

Private Sub DeleteThis_Click()
On Error GOTO Err-DeleteThis_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Exit_DeleteThis_Click:
Exit Sub

Err_DeleteThis_Click:
MsgBox err.Description
Resume Exit_DeleteThis_Click
End Sub

The RecordSource is a table "tblStorageItems"

I guess I just assumed that anytime someone used the
wizard it generated the same code so everyone knew the
code generated. I apologize for not submitting it
previously. I can't find in any of my several books, or
the help menu, anything about the DoMenuItem, the
acFormBar, the acEditMenu, the acMenuVer70, etc. Is there
a good reference that shows all the posssible commands and
properties, etc that are available in Access 2002?

Thanks again Graham.

I just tried your code, same results.

Microsoft Access "Property not found"
-----Original Message-----
Hi Dave

I have no idea what code the wizard produced for you,
but
it was probably
written by Noah in the Ark.

Try this:
DoCmd.RunCommand acCmdDeleteRecord

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

I want to delete the current record in a form. I have
created a command button with the wizard and selected
record operations and delete record.

When I try to delete the current record it deletes but
gives me a message box "Property not Available". I have
to click OK to finish, then the deleted record still shows
in the combo box.

Any ideas what I could have done wrong or not right?


.
.
 
Hi Dave

Sorry about the complete silence yesterday - I got distracted by some pesky
clients.

Do you know exactly where the error is occurring? I'm pretty sure it's not
in your DeleteThis_Click event procedure, because none of it is referring to
any property. It could be in some other code which is triggered when the
focus changes to a new record, because the current one has been deleted.

I suggest you go to Tools>Options (from the VB window) and set the "Break on
all errors" option. Then run the code again and see where it stops.

You will need to requery the combo box after deleting the record to remove
it from the list (MyCombo.Requery).

DoMenuItem is old (V2) code which still works, but is almost entirely
obsolete. That wizard code was written back in Access 95, before RunCommand
was invented. OK - it wasn't Noah... but it must have been a near relative
:-)

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

dave said:
-----Original Message-----
I lived in and around Auckland for two years, love your
sense of humor on the code. Here is the code generated by
Noah's wizard:

Private Sub DeleteThis_Click()
On Error GOTO Err-DeleteThis_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Exit_DeleteThis_Click:
Exit Sub

Err_DeleteThis_Click:
MsgBox err.Description
Resume Exit_DeleteThis_Click
End Sub

The RecordSource is a table "tblStorageItems"

I guess I just assumed that anytime someone used the
wizard it generated the same code so everyone knew the
code generated. I apologize for not submitting it
previously. I can't find in any of my several books, or
the help menu, anything about the DoMenuItem, the
acFormBar, the acEditMenu, the acMenuVer70, etc. Is there
a good reference that shows all the posssible commands and
properties, etc that are available in Access 2002?

Thanks again Graham.

I just tried your code, same results.

Microsoft Access "Property not found"
-----Original Message-----
Hi Dave

I have no idea what code the wizard produced for you,
but
it was probably
written by Noah in the Ark.

Try this:
DoCmd.RunCommand acCmdDeleteRecord

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

I want to delete the current record in a form. I have
created a command button with the wizard and selected
record operations and delete record.

When I try to delete the current record it deletes but
gives me a message box "Property not Available". I have
to click OK to finish, then the deleted record still shows
in the combo box.

Any ideas what I could have done wrong or not right?




.
.
 
Back
Top