Error Using DoCmd.RunSQL delete into

Posted on 2003-03-26
Medium Priority
Last Modified: 2008-03-03
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
Question by:TutoStyle3
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
  • 2
LVL 41

Accepted Solution

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

Expert Comment

ID: 8211854
perhaps you'll have to use

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


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

Expert Comment

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

Author Comment

ID: 8212172
thx man
works good

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

752 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