Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Error Using DoCmd.RunSQL delete into

Posted on 2003-03-26
4
Medium Priority
?
766 Views
Last Modified: 2008-03-03
Hi
i got a Listbox(delDirection) that is connected to 1 table(direction)
then i got a cmdButton that delete the data that is selected in the ListBox.
thats the command i use, but i have an error. the Insert To worked with a Textbox, but now i have a listbox.


DoCmd.RunSQL "delete into Direction (Direction) values(delDirection.value)"
//error here
0
Comment
Question by:TutoStyle3
  • 2
4 Comments
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 80 total points
ID: 8211712
The syntax of an SQL DELETE statement (in Jet) is:
DELETE * FROM <tablename> WHERE <conditions>

If your list box contains the primary key of the table, you need something like:
DoCmd.RunSQL "DELETE * FROM Direction WHERE DirectionID=" & Me!delDirection
0
 
LVL 2

Expert Comment

by:stewal
ID: 8211854
perhaps you'll have to use

docmd.execute "DELETE * FROM Direction WHERE DirectionID=" & delDirection.list(deldirection.listindex)

OR

docmd.runsql "DELETE * FROM Direction WHERE DirectionID=" & delDirection.list(deldirection.listindex)
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 8211994
The .List property is a property of the command-bar combo box - not a form listbox.
0
 

Author Comment

by:TutoStyle3
ID: 8212172
thx man
works good
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Question has a verified solution.

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

I have had my own IT business for a very long time. I started mostly with hardware and after about a year started to notice a common theme. I had shelves with software boxes -- Peachtree, Quicken, Sage, Ouickbooks -- and yet most of my clients were…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

580 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