Need to delete record and can't figure out how...

  • Thread starter Thread starter crckrs9
  • Start date Start date
C

crckrs9

Guest
Very new to Access and not a VB programmer. :confused:

With that in mind, I have created form for users to record address changes of members. I want to have a button that will "undo" what a user entered if they change their mind/decide an address change not necessary. My address change table has an auto-number field (ID) that is the index and I believe Access automatically creates a record regardless so how do we get rid of it?

I did a search and keep reading about a button wizard - Huh??? I don't know how to activate a button wizard (told you I was new). Also, I read about adding code but to where? and how? It also appeared the code examples might be using psuedo-names for tables or something ... how do I know a "real" name from a psuedo-name?

Can a "Delete" query be written? if so, what is the criteria to use?

I've looked at the properties of the button and all I can see is a place to add a macro or an expression. Am I in the wrong place for what I want to do?

Can anyone offer some help here?

Thanks!
 
to delete a record, go to the design view of your form, from the Toolbox, select the command button, and draw a button, go to its properties, and select the onClick event, and put the following line of code:

DoCmd.RunCommand acCmdDeleteRecord
 
Ok - did that and got an error message stating Access can't fid a macro named Do.Cmd...

I put the line DoCmd.RunCommand acDeleteRecord in the entry space next to OnCLick (event tab) - that is the right place, correct???? :(
 
Make a commad button...right click properties....event tab...place your insertion point on click event you should see 3 little black dots...click on the black dots...code builder...paste this code...DoCmd.RunCommand acCmdDeleteRecord...close the vb form and be sure to save the form before going to form view.

hth,
Michael
 
No, not the right place. Hit the button with the three dots on that line and select Code Builder. ;)
 
GOT IT! Thank you...

I tested and record doesn't get written - SUPER!!!!...

Next question is can I add another line of code to to the "On Click" event to also undo what was typed in? If so what would I add?
 
Hi Crckrs9,

crckrs9 said:
Next question is can I add another line of code to to the "On Click" event to also undo what was typed in? If so what would I add?

Me.Undo
 

Users who are viewing this thread

Back
Top Bottom