Solved

RE: Deleting Access Records

Posted on 1998-07-04
5
136 Views
Last Modified: 2010-05-03
I have a problem with a ListBox linked to a database...... What I want to do is get the list box's index for an item,
Then delete that Item out of the database..Simple IF you know how (I Don't)

0
Comment
Question by:MAVERICK
  • 3
5 Comments
 

Expert Comment

by:vamsi_k
Comment Utility
Using the list box's index, you could get the item in the list box, and use that item in the loop for searching the database, and if matched, delete that record.  If you still did not get the idea, I will write the code.

Regards,
Vamsi
0
 
LVL 1

Author Comment

by:MAVERICK
Comment Utility
I'm familiar with the concept but I really would like some code... I tried to do it similarly to the method you suggested but it didn't work

0
 
LVL 1

Author Comment

by:MAVERICK
Comment Utility
I've rejected the answer because I really need the FULL code pretty soon!!
 to do the 'simple'  task.....

0
 

Accepted Solution

by:
esdhem earned 200 total points
Comment Utility
I assume the event is listbox_click?
You need a DB component in your app maybe DAO 3.5 would be cool
it works on Access Tables

declare your DB
Public MyDatabase As Database
Dim MyRecordset As Recordset

you will need to initialize

Public Sub InitializeDatabases()
    Set MyDatabase = OpenDatabase(App.Path + "\MyData.mdb")
End Sub

set myrecordset = mydatabase.openrecordset("MyDataTable",dbopentable)

Now you can edit your DB
use a seek command in conjunction with your index from your listbox.index you capture on the click.
to take care of the situation of an empty table use
if myrecordset.recordcount=0 then
  msgbox"No Record"
else
  myrecordset.delete
  myrecordset.update
endif


0
 
LVL 1

Author Comment

by:MAVERICK
Comment Utility
I tried the code....... I still couldn't match it to the index... it... My friend solved the problem.....Thanks....


0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now