If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
delete button in a form
I got 3 records in a table and I have a form where the source is based on
this table. Now I created a delete button from toolbox wizard and it should delete the current record. If I press that button, the current record on the form is empty out instead of deleted. After deletion, there are 3 records and 1 is all empty. How can I make it deleting a record instead of empty out the record? I am running access 97. Please help. Thanks. |
#2
|
|||
|
|||
delete button in a form
Try this code instead of what the wizard wrote:
If Me.Dirty Then Me.Undo If Not Me.NewRecord Then RunCommand acCmdDeleteRecord Note that the 3rd record could be the "new record" row of the form. If so, it will show "Record 2 of 2" when you move back to the previous one. -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. " 00 Michael Jordan" wrote in message ... I got 3 records in a table and I have a form where the source is based on this table. Now I created a delete button from toolbox wizard and it should delete the current record. If I press that button, the current record on the form is empty out instead of deleted. After deletion, there are 3 records and 1 is all empty. How can I make it deleting a record instead of empty out the record? I am running access 97. Please help. Thanks. |
#3
|
|||
|
|||
delete button in a form
If the record is "emptied out" then it had been deleted! An "empty" record on
a form is actually a new record, awaiting data! If you delete a record from a form, by default Access moves on and displays the next record in order.If the record deleted is the last record in the displayed recordset, which I expect it is in your case, Access still moves on to display the next "record" which in this case is a new or blank record. If you prefer some other behavior, you'll have to add that to your button's deetion code. Me.Requery, for ewxample,will take you to and display the first record. 00 Michael Jordan wrote: I got 3 records in a table and I have a form where the source is based on this table. Now I created a delete button from toolbox wizard and it should delete the current record. If I press that button, the current record on the form is empty out instead of deleted. After deletion, there are 3 records and 1 is all empty. How can I make it deleting a record instead of empty out the record? I am running access 97. Please help. Thanks. -- There's ALWAYS more than one way to skin a cat! Answers/posts based on Access 2000 Message posted via http://www.accessmonster.com |
#4
|
|||
|
|||
delete button in a form
I tried the code but still the same. I still got 3 got records with one
empty records and after refresh, the empty record goes to the first record. "Allen Browne" wrote in message ... Try this code instead of what the wizard wrote: If Me.Dirty Then Me.Undo If Not Me.NewRecord Then RunCommand acCmdDeleteRecord Note that the 3rd record could be the "new record" row of the form. If so, it will show "Record 2 of 2" when you move back to the previous one. -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. " 00 Michael Jordan" wrote in message ... I got 3 records in a table and I have a form where the source is based on this table. Now I created a delete button from toolbox wizard and it should delete the current record. If I press that button, the current record on the form is empty out instead of deleted. After deletion, there are 3 records and 1 is all empty. How can I make it deleting a record instead of empty out the record? I am running access 97. Please help. Thanks. |
#5
|
|||
|
|||
delete button in a form
In that case, you will need to delete that empty record from your table,
and/or figure out what is causing it to be created all the time. -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. " 00 Michael Jordan" wrote in message ... I tried the code but still the same. I still got 3 got records with one empty records and after refresh, the empty record goes to the first record. "Allen Browne" wrote in message ... Try this code instead of what the wizard wrote: If Me.Dirty Then Me.Undo If Not Me.NewRecord Then RunCommand acCmdDeleteRecord Note that the 3rd record could be the "new record" row of the form. If so, it will show "Record 2 of 2" when you move back to the previous one. " 00 Michael Jordan" wrote in message ... I got 3 records in a table and I have a form where the source is based on this table. Now I created a delete button from toolbox wizard and it should delete the current record. If I press that button, the current record on the form is empty out instead of deleted. After deletion, there are 3 records and 1 is all empty. How can I make it deleting a record instead of empty out the record? I am running access 97. Please help. Thanks. |
#6
|
|||
|
|||
delete button in a form
I added me.requery at the end of code. After I press the delete button, the
empty record is shown in the form and when I try to go to previous record, it gives me a msg window as following: Update or CancalUpdate without AddNew or Edit. After I click the OK button, it stayed in the same form and I am stucked. Please help. Thanks. "Linq Adams via AccessMonster.com" u28780@uwe wrote in message news:79227467cc451@uwe... If the record is "emptied out" then it had been deleted! An "empty" record on a form is actually a new record, awaiting data! If you delete a record from a form, by default Access moves on and displays the next record in order.If the record deleted is the last record in the displayed recordset, which I expect it is in your case, Access still moves on to display the next "record" which in this case is a new or blank record. If you prefer some other behavior, you'll have to add that to your button's deetion code. Me.Requery, for ewxample,will take you to and display the first record. 00 Michael Jordan wrote: I got 3 records in a table and I have a form where the source is based on this table. Now I created a delete button from toolbox wizard and it should delete the current record. If I press that button, the current record on the form is empty out instead of deleted. After deletion, there are 3 records and 1 is all empty. How can I make it deleting a record instead of empty out the record? I am running access 97. Please help. Thanks. -- There's ALWAYS more than one way to skin a cat! Answers/posts based on Access 2000 Message posted via http://www.accessmonster.com |
#7
|
|||
|
|||
delete button in a form
I figured out this problem only happens when I delete the last record. Any
help? Thanks. " 00 Michael Jordan" wrote in message ... I added me.requery at the end of code. After I press the delete button, the empty record is shown in the form and when I try to go to previous record, it gives me a msg window as following: Update or CancalUpdate without AddNew or Edit. After I click the OK button, it stayed in the same form and I am stucked. Please help. Thanks. "Linq Adams via AccessMonster.com" u28780@uwe wrote in message news:79227467cc451@uwe... If the record is "emptied out" then it had been deleted! An "empty" record on a form is actually a new record, awaiting data! If you delete a record from a form, by default Access moves on and displays the next record in order.If the record deleted is the last record in the displayed recordset, which I expect it is in your case, Access still moves on to display the next "record" which in this case is a new or blank record. If you prefer some other behavior, you'll have to add that to your button's deetion code. Me.Requery, for ewxample,will take you to and display the first record. 00 Michael Jordan wrote: I got 3 records in a table and I have a form where the source is based on this table. Now I created a delete button from toolbox wizard and it should delete the current record. If I press that button, the current record on the form is empty out instead of deleted. After deletion, there are 3 records and 1 is all empty. How can I make it deleting a record instead of empty out the record? I am running access 97. Please help. Thanks. -- There's ALWAYS more than one way to skin a cat! Answers/posts based on Access 2000 Message posted via http://www.accessmonster.com |
#8
|
|||
|
|||
delete button in a form
I have worked around the problem. By adding the following code to load form
event: Me.AllowAdditions = False and set it to right for unload form event. " 00 Michael Jordan" wrote in message ... I figured out this problem only happens when I delete the last record. Any help? Thanks. " 00 Michael Jordan" wrote in message ... I added me.requery at the end of code. After I press the delete button, the empty record is shown in the form and when I try to go to previous record, it gives me a msg window as following: Update or CancalUpdate without AddNew or Edit. After I click the OK button, it stayed in the same form and I am stucked. Please help. Thanks. "Linq Adams via AccessMonster.com" u28780@uwe wrote in message news:79227467cc451@uwe... If the record is "emptied out" then it had been deleted! An "empty" record on a form is actually a new record, awaiting data! If you delete a record from a form, by default Access moves on and displays the next record in order.If the record deleted is the last record in the displayed recordset, which I expect it is in your case, Access still moves on to display the next "record" which in this case is a new or blank record. If you prefer some other behavior, you'll have to add that to your button's deetion code. Me.Requery, for ewxample,will take you to and display the first record. 00 Michael Jordan wrote: I got 3 records in a table and I have a form where the source is based on this table. Now I created a delete button from toolbox wizard and it should delete the current record. If I press that button, the current record on the form is empty out instead of deleted. After deletion, there are 3 records and 1 is all empty. How can I make it deleting a record instead of empty out the record? I am running access 97. Please help. Thanks. -- There's ALWAYS more than one way to skin a cat! Answers/posts based on Access 2000 Message posted via http://www.accessmonster.com |
Thread Tools | |
Display Modes | |
|
|