473,387 Members | 1,504 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,387 software developers and data experts.

Using a list box to select a record to delete

66
Hi,

A section of my database allows users to delete items from a table, there is only one collumn in the table, this contains module information(parts of a manufacturing line) due to the lines regulary changing i added a section to delete modules. so far ive got the combo box which selects the modules from a table using a select query, when a specific module is selected i need it to be deleted.

the problem im having is when the delete button is pressed it deletes the top item in the table not the one selected.

i tried resolving this so when the list box item is clicked whatever module has been selected gets put into an invisible text box on the form, and when the delete button is pressed it is supposed to delete whatever is in the text box but i am getting the same problem (deletes first item in table not the one selected)

here is the code that is used on the deleted button and combo box:
--------------------------------------------------------------------------------------------------
Private Sub cmddel_Click()
'Yes/No opetion box
RetValue = MsgBox("Are you sure you want to delete this module", vbOKCancel)

'if the value equals yes then module is deleted
If RetValue = 1 Then
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
'DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
cmbmodlookup.Requery
cmbmodlookup = ""
End If

End Sub


Private Sub cmbmodlookup_click()

DoCmd.ShowAllRecords
Me!txtmodule.SetFocus
DoCmd.FindRecord Me!cmbmodlookup
Me!cmbmodlookup.SetFocus

End Sub
--------------------------------------------------------------------------------------------------------------

any help or suggestions would be great
Apr 25 '07 #1
2 2155
MMcCarthy
14,534 Expert Mod 8TB
Run a Delete query. Always remember to back up your database before trying something like this.
Expand|Select|Wrap|Line Numbers
  1. Dim strSQL As String
  2.  
  3.    strSQL = "DELETE * FROM TableName WHERE [FieldName]='" & Me!cmbmodlookup & "'"
  4.    DoCmd.RunSQL strSQL
  5.  
Mary
Apr 25 '07 #2
jasone
66
ok cheers once again lol!

i will give it a go and hopefully it will work.
Apr 25 '07 #3

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

Similar topics

8
by: tom | last post by:
I am new to SQL administration. >From a list of IDs that are the primary key in one table (i.e. Customer Table), I want to make changes in tables that use those IDs as a foreign key. ...
6
by: Robin S. | last post by:
Originally I wanted a list box which selects which record is the current one within the same form. Easy enough until Access takes a dump when one is deleted and then someone tries to select it in...
1
by: Ryan | last post by:
Hello, I have a quick question (I hope). I have a form with a combo box and a multi-selection list box. The list box is based on a query. Users can select values from the cmbobox to add to...
8
by: doomx | last post by:
I'm using SQL scripts to create and alter tables in my DB I want to know if it's possible to fill the description(like in the Create table UI) using these scripts. EX: CREATE TABLE(...
8
by: sara | last post by:
I am learning Access and programming. I wanted to have the user select the departments for an ad from the list of all departments. Found code (that I could understand) on this site, and it works....
2
by: rich | last post by:
I am building a database and I am using a list where I can make multiple choices. The data is like this Master table item1id item2 index(item1id) detail table item1id
1
by: dabbakal | last post by:
Hello, am a new member and this is my first posting. C++ is the first progrsaming language am taking and is just for 3 months. Having benefited from lot of posting i decided to join. But currently...
1
by: Sunray | last post by:
I have a form called the sales form and i have 2 sets of listboxes So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which...
1
debasisdas
by: debasisdas | last post by:
Using Co-related sub query ======================== While a subquery is evaluated only once for each table, a correlated subquery is evaluated once for each row. Sub query can take value from...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.