473,408 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

delete table based value from listbox

Hi everyone,

i've a problem when i trying to delete a record in table based a value from listbox. Can someone give me an idea on it...

Thanks.
Mar 28 '08 #1
2 1563
Put this code in the onclick event of a button. You'll need to change the names to match your field name, your tablename and your listboxname. Be sure the field you reference in your table is the same field that is contained in your listbox.

Dim curLstVal
dim strSql as string

curLstVal= me.mylistboxname

strSql = "Delete from tblMyTable where fldMyfield = " & curLstVal & "

docmd.runsql(strSql)

msgbox"Record deleted"
Mar 28 '08 #2
Hi everyone,

i've a problem when i trying to delete a record in table based a value from listbox. Can someone give me an idea on it...

Thanks.
I should have added, another way to do it is this (first get your listbox value like in the last example):
dim curVal
dim rs as recordset
dim strsql as string

curval=myListBox.value

strsql="Select * from myTable where myField = " & curVal & "

set rs= currentdb.openrecordset(strsql)

if not rs.eof then
'go on
else
exit sub
end if
with rs
.delete
end with

msgbox"Recordset deleted"
Mar 28 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: php newbie | last post by:
I am getting error messages when I try to delete from a table using the values in the table itself. The intent is to delete all rows from TableA where col_2 matches any of the col_1 values. ...
16
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the...
2
by: Remco Groot Beumer | last post by:
Hello, I created a program in which I use modules and classmodules for setting my variables. For example when I need to set the customerID in a variable I use something like: ...
2
by: mike | last post by:
Hi All I have a listbox which has a table as its row source. I want to be able to choose from this listbox (which has approximately 8 records) and have this value entered into another table (it...
2
by: jim Bob | last post by:
Hi, I have a form with a list box that shows the contents of a table and managed to create an add record button with the wizard. (DoCmd.GoToRecord , , acNewRec) Now i want to make a delete...
5
by: agarwasa2008 | last post by:
Hi, I would like to delete a record based on a user entered string. Here are the details. I have a txtFind textbox. A string is entered by the user. Based on that string value it displays that...
11
by: Ed Dror | last post by:
Hi there, I'm using ASP.NET 2.0 and SQL Server 2005 with VS 2005 Pro. I have a Price page (my website require login) with GridView with the following columns PriceID, Amount, Approved,...
7
by: BONES7714 | last post by:
Hello, This is my first post to any sort of forum although I've used them to learn the very little Access/VBA that I know so please forgive my ignorance. I work for the National Guard as Combat...
1
by: angelicdevil | last post by:
i have listbox 1 which displays status , based on selection of status listbox 2 displays usernames. and based on username selected the textbox displays the email id. its working fine till...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.