hey all,
I'm using this code on a command button to delete single entries in a listbox... and it works fine
Private Sub DeleteMovie_Click()
CurrentDb.Execute "Delete from " & _
"tblMovies " & _
"where Title = """ & Me.lstList & """", dbFailOnError
Me.Requery
Me.lstList.Requery
Me.lstList = ""
End Sub
However, I want to try to select and delete multiple items in the list box. So I changed the property to allow multiple selections and now the button doesn't do anything when I click it. Ideally, I'd like the button to provide a "are you sure (yes or no)" prompt. Anyone know how to get this working? thanks a bunch
My issue is that I have a listbox which works off the quiery:
SELECT Subscription.Investor_ID, Subscription.Date, Subscription.Transaction, Subscription.Units, Subscription.NAV, Subscription.Amount FROM Investors INNER JOIN Subscription ON Investors.Investor_ID = Subscription.Investor_ID ORDER BY Subscription.Date;
Unfortunately, this shows all the details for all the Investor_ID's. I would like to filter out the 'Investor_ID' entries which do not correspond to my Investor_ID text box.
Any ideas? I can use VBA to find any rows that do not correspond, but I can't figure out how to delete them.
I have a combo box that inserts data into an unbound list box and table. This works great but I am having trouble with the deletion part. I want to be able to dbl click on the item in the item list and delete it from both the list box and table. Currently, my code is deleting ALL items, not just the one item I want to get rid of. Any ideas would be most appreciated :) This is what I have for the deletion code:
Private Sub List92_DblClick(Cancel As Integer) DoCmd.SetWarnings False sql2 = "delete from PROFILE_Industry where " sql2 = sql2 & "profile_id = " & Me!Profile_ID sql2 = sql2 & " And Industry_focus = '" & Me!List92.Value & "';" DoCmd.RunSQL (sql2) Me.Refresh DoCmd.SetWarnings True End Sub
1. Persons (list of persons) 2. Job history (list of jobs)
each person have their own job history. all these jobs are stored in the job history table. when i delete a person i would like the job history for this person deleted as well. each job stored in the job table have a field with person name, so that it is linked to this person.
how can i do this? vba or simple properties options?
I have two tables (same data but slightly different attribute structure) with a one-to-one relationship (the join field is "ID"). There are 69 matching records in these tables. How can I delete these matching records from table A, while leaving them alone in table B?
I'm confused because I brought both tables into a select query, created a join from ID to ID (within in the query's design view), and then added all fields from table A to the query. I then ran the select query and saw the 69 records from table A in the query's data view that I wanted to delete, highlighted all records and clicked delete. However, this action deleted the 69 matching records from TABLE B, not Table A!!! How is this possible? What should I do instead? Thanks.
A strange request but I hope someone can help with this one
I have a table (tbl_Econ) where I have to delete a specified number of records from a table. It does not matter which records as long as I delete the exact number
e.g On a form text box I enter the number or records to be deleted (e.g.6000).
The table (tbl_Econ) has 8000 records, so I have to delete 6000 records. I need to be able to do this automatically :eek:
how would i go about deleting a set of records? i can get a list of records together in a query taken from 4 tables and would need to, if necessary, delete a single line. not all information needs to be deleted from all 4 tables though? the info to be deleted would only be deleted from 1 or 2 tables being the last 2 in the relationship.
i guessed it might be an append query but im not too familiar with them.
Hi there, i have a master reset to delete all the data in the database. Although, as there is a username and password entry to get into the admin module, i wish for one entry in the table participantTable to not get deleted (to save one password/username so its possible to log into the admin module after the reset). The code below will delete everything, how can i change it so it keeps the first record in the table, and then deletes all the other records after.
Inside you can find one form with listbox (with multi selecting ability).
I use this code :
Dim strSQL As String Dim i As Variant With Me.se1 For Each i In .ItemsSelected SQL = "DELETE '*' FROM [t1] WHERE [id] = " & .ItemData(i) & " ;" CurrentDb.Execute (SQL) Next End With Me.se1.Requery
Result is this one : 1) If I delete only one item in list, it is ok. I can do it again and again and it is working fine.
BUT
2) If I delete more items in list at once, it is ok - but if I will try to do it again then there is an error because .ItemData(i) value is Null.
if i have a sales order that the sales order # is an autonumber and i manually delete the records my next new record still follows the last number i had before that is now deleted..
example
sales order 1001 sales order 1002
if i delete all the records on the table and clean it all out
the next new autonumber will be 1003...
i want it to be 1001 again... and yes its set to an index of no dups
I have 3 tables: 1. customer 2. DVD collection 3. Borrow
The aim of this system is to create a home borrowing system.
The customer table has a one to many relationship with the borrow table, while the dvd collection has a one to one with borrow. I can create a new book with no problem, and even view these on a form. Here my proble arises.
I ahve another form to return a DVD. I view the records from the borrow table, and once found what i want there is a button which deletes the record from the borrow table. Sadly, when i press this button, not only does it delete the record in the borrow table, but it will also delete the record from the DVD collection table.
I have tried everything i can think of, and i don't want to change to change the design as i have found this mnethod very easy to generate reports and the like. Any help??
Thanks
EDIT: the button i used was from the wizard that comes up when you create a button.
I am using a large database, which usually works fine, and is set to compact on close.
Occasionally it has been losing a lot of data in the main table, probably when it compacts, down to a round number of records. This time it left me with 10,000 records exactly. (It has been different round numbers before)
Does anyone have any ideas as to what is causing this?
if i have a sales order that the sales order # is an autonumber and i manually delete the records my next new record still follows the last number i had before that is now deleted..
example
sales order 1001 sales order 1002
if i delete all the records on the table and clean it all out
the next new autonumber will be 1003...
i want it to be 1001 again... and yes its set to an index of no dups
Hi, I am using Vb6.0 as a front end and msaccess as the db. i want 2 delete all the records in a table "Register" by clicking a menu The connection is made using ADODB Till now i hv the code
Private Sub mnudel_Click() Docmd.SetWarnings False Docmd.RunSql ("DELETE * FROM Register;") Docmd.SetWarnings True End Sub
But when i execute this a error msg displays Run time error "424" Object required
Whats the problem in me plz help me to come out from this...
i know this must be a piece of cake but i'm new to Access!
Anyway, am using a delete query and want an expression that i can use in the criteria to allow me to detect (and delete) records that are 5 years old. i used Date() - 1825 but was wondering if there was any other way or function that would allow me to acheive this. any help regarding this would be appreciate! hope someone can help.
I am having problems deleting various rows from an SQL table, the message coming up is "The row value(s) updated or deleted either do not make the row unique or they alter multiple rows (xxrows). Any Suggestions?
I have a simple form with a subform on it (see enclosed Access 2000 Database). I'm trying to add/change/delete records from table: Component Name. Adding and changing records is not a problem but deleting is. It only deletes the value of the field "Interative Component Name" and not the entire record. I have my joins defined properly on the tables. What am I missing? I wish this Access stuff was easier to learn. Any help/clues would be greatly appreciated.
I have a "display only" subform that is updated by a popup form. If I add or amend an entry the details of the changes are displayed immediately in the display window by requerying the form "afterupdate". However, I have a delete button on my popup form which will delete a record but replaces it with the word #deleted in each of its fields. The #delete will only disappear once I have moved to another record which I don't want to do.
Can any one tell me why the amend/insert update works well but the delete behaves in this way.
How can I set up the delete function to function and remove the #deleted message without moving to another record. I have tried adding a save button but this doesn't fix it.
I have a form with a search field for an unique field, that looks up records in the table that belong to that unique field. See Code:
Private Sub cboLastName1_AfterUpdate() On Error Resume Next
Dim db As DAO.Database Dim rs As DAO.Recordset Dim strSQL As String
cboLastName1.SetFocus If cboLastName1.Value > 0 Then strSQL = "SELECT * FROM tbl24HRPolicies WHERE AutoNumber = " & cboLastName1.Value
Set db = CurrentDb Set rs = db.OpenRecordset(strSQL) If Not rs.BOF Then Me.ID = rs("AutoNumber") Me.Prefix = rs("PolicyNumber") Me.FirstName = rs("DateReceived") Me.MiddleName = rs("Comments") Me.LastName = rs("ClientsName") Me.Suffix = rs("ShopID") Me.NickName = rs("Nickname") Me.Title = rs("ActivePolicy") End If rs.Close Set rs = Nothing db.Close Set db = Nothing End If
The fields, that take content based on that search field, are unbound. I've added the delete button, but it's not working, because they are unbound. Is there no way to delete records with this form??