Solved

RE: Deleting Access Records

Posted on 1998-07-04
5
140 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…

726 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