Solved

RE: Deleting Access Records

Posted on 1998-07-04
5
137 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
ID: 1464945
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
ID: 1464946
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
ID: 1464947
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
ID: 1464948
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
ID: 1464949
I tried the code....... I still couldn't match it to the index... it... My friend solved the problem.....Thanks....


0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

920 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