473,513 Members | 2,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Delete Info from a Table

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!
Nov 13 '05 #1
3 2006
Look into using the Delete Action Query. You can pass parameters from your
form and run the query from code on the button on your form.

HTH
Paul

"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!

Nov 13 '05 #2
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!

Nov 13 '05 #3
Squirrel, Thanks for your reply, Looks great I'll give it a shot.
Thanks
S. Graefner

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
7470
by: jim | last post by:
I have two tables that are related by keys. For instance, Table employee { last_name char(40) not null, first_name char(40) not null, department_name char(40) not null, age int not null, ......
5
5071
by: Jucius | last post by:
Using Delphi for developing, I get and delete records from an Access Database 2000. Sometimes, It happened 3 times (but not reproductible), the application did not succeed in connecting the...
5
14596
by: Tony | last post by:
hi NG I have got a database, and from this database I want to delete a table in another database, before Iexport a new table to that other database. My question is how can I delete a table in...
4
10614
by: Ian | last post by:
Hi, I have a problem with delete using where in clause. This is a query: delete from tab1 where id not in (select id from tab2) I calculated costs using select instead of delete: select...
10
2667
by: nickvans | last post by:
Hello everyone, I'm fairly new to VBA and MS Access (I'm using 2003) but my issue seems like a pretty straight forward one. I would like to delete all records found in one table from another one. ...
2
1661
vanc
by: vanc | last post by:
I'm trying to delete a table with just around 2000 rows. What I got is timeout error. I can't use Truncate Table, which is very quick, because I have Trigger with Delete command. Is there any way to...
3
1600
topher23
by: topher23 | last post by:
I have a query that isn't working as expected. The query links to one table used for data entry and has outer joins on two tables used to display information based on choices entered. I can...
0
884
by: steve proctor | last post by:
run time 70 permissions denied trying to update( delete info) on a vista Pc, how do i get round this, some say MTS??? but can't find that anywhere on the vista Pc, (using VB6)created the program on...
0
7257
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7157
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7521
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1591
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.