Deleting a record through a button in a form?

Shellie

Registered User.
Local time
Today, 13:07
Joined
Mar 10, 2006
Messages
18
Help needed! (Apologies if this is a stupid question !)

I'm making a database for my OCR A2 coursework.

I have a table set up for tenants, and have created a form through which the user can delete a record from that table.

I have a look up combo box, to select the record (tenant) for deletion, and a command button - using the wizard that came up I have selected "delete record" - but it doesnt work! It doesn't delete the record i have selected.

Why Is this not happening ? It also doesn't bring up a warning box saying "you are about to delete one record" or something similar?

Thanks xzxx
 
What code do you have behind the Command button and what do you have in the AfterUpdate event of the ComboBox?
 
nothing at all. I didn't know how to use a macro - as the macro would only allow me to delete whole objects ie tables as opposed to single records?
 
In design view select the Delete command button and right click and select properties. Go to the Event tab and press the ... button on the Click event line next to where you see [Event Procedure]. Copy everything in that subroutine and paste it into a post here between
Code:
code
tags.
 
RuralGuy said:
In design view select the Delete command button and right click and select properties. Go to the Event tab and press the ... button on the Click event line next to where you see [Event Procedure]. Copy everything in that subroutine and paste it into a post here between
Code:
code
tags.


Code:
Option Compare Database

Private Sub Command3_Click()
On Error GoTo Err_Command3_Click


    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Exit_Command3_Click:
    Exit Sub

Err_Command3_Click:
    MsgBox Err.Description
    Resume Exit_Command3_Click
    
End Sub
Private Sub Command6_Click()
On Error GoTo Err_Command6_Click


    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Exit_Command6_Click:
    Exit Sub

Err_Command6_Click:
    MsgBox Err.Description
    Resume Exit_Command6_Click
    
End Sub
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click


    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Exit_Command8_Click:
    Exit Sub

Err_Command8_Click:
    MsgBox Err.Description
    Resume Exit_Command8_Click
    
End Sub

Thanks x
 
Hi Shellie,
Any chance you can zip up your db and attach it to a post here? Remove any sensitive data. It would make things quicker here.
 
I can try :P

Gimme a sec - can you tell Im not expecting an A at A-level :P xx
 
No problem. You're doing just fine. Everyone had to start somewhere.
 
Last edited:
Hi Shellie,
All I did was bind the form to the tblTenants table and add some code to the AfterUpdate event of the ComboBox. Thank goodness for Referential Integrity (RI). I'll leave it for your exercise to figure out what needs to be done next. Post back here if you're really stumped.
 

Attachments

Users who are viewing this thread

Back
Top Bottom