Hi Stewart,
Put a command button on a form, call it cmdDeleteData
Right click on the button with the form in Design View and select
Properties.
Select the Event tab and click on the line beside On Click.
The [...] button will appear, click on this and then doubleclick on "Code
builder".
This will open the form module for your code and will write the first and
last lines of the
subroutine for you.
The code you need is below:
Paste it inside the two lines written for you i.e.
Private Sub cmdDeleteData_Click()
Exit Sub
and then delete the duplicate first and last lines.
Code requires that your command button be called cmdDeleteData and there's a
note on
the relevant line where you need to modify the code and use the name of YOUR
table.
Suggest obviously copying your table to e.g. tblVacationsBackup before
running this code.
Code will give you two opportunities to cancel the delete operation.
Hope this helps.
Linda
Private Sub cmdDeleteData_Click() ' command button name is cmdDeleteData
On Error GoTo cmdDeleteData_Err
Dim sTableName As String
Dim iResponse As Integer
sTableName = "tblVacations" ' replace with your Table name
iResponse = MsgBox("Delete ALL rows from the Vacations table." & vbCrLf & _
vbCrLf & "ARE YOU SURE?", vbYesNoCancel, _
"THIS OPERATION WILL DELETE ALL THE ROWS IN YOUR VACATIONS TABLE!")
If iResponse = vbYes Then
DoCmd.RunSQL "Delete from " & sTableName
End If
cmdDeleteData_Exit:
Exit Sub
cmdDeleteData_Err:
MsgBox Err.Description & vbCrLf & "cmdDeleteData"
Resume cmdDeleteData_Exit
End Sub
"Stewart Graefner" <gr*******@hotmail.com> wrote in message
news:41**********************@news.newsgroups.ws.. .
What do I need to use to be able to make information in a table be
deleteable by a User? The table I have tracks Vacation time. It has two
fields Vacation Dates and Days taken(Default value 0). The Form used has
four rows of the above for each month of the year. The clerk inputs the
vacation dates and the days of vacation time remaining are tallied at
the bottom of the form. There are inexcess of 200 hundred employees.
Rather than have the clerk manually go through the form for each
employee and delete his or her info at the end of the fiscal year I
would like to have a Button on the form, preferably with a second chance
notification, which resets the Table to Zero. I dont belive that a make
table query is the answer but dont know what is.
Thanks
S. Graefner
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!