?
Solved

RE: Deleting Access Records

Posted on 1998-07-04
5
Medium Priority
?
142 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 400 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month13 days, 11 hours left to enroll

801 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