Delete Record Selected In Combobox (1 Viewer)

a.sinatra

quik
Local time
Today, 02:10
Joined
Jan 10, 2004
Messages
262
delete reocrds from combo box

i cant del records from a combo box, its just selects the first in the combo box then it deletes it instead of deleting the one i clicked on, any help would be greatly appreciated! thank you
________
Mercedes-benz clk-class specifications
 
Last edited:

WayneRyan

AWF VIP
Local time
Today, 10:10
Joined
Nov 19, 2002
Messages
7,122
asinatra,

Can't read it.

What version of Access is that? You'd be better off posting an
A97 or A2000 version.

Wayne
 

Mile-O

Back once again...
Local time
Today, 10:10
Joined
Dec 10, 2002
Messages
11,316
The form you are using to delete stuff from is unbound so you can't simply delete the current record as it doesn't exist on that form.

All you are doing is putting a query into a combobox. This does not bind it to the form.

Your best bet, from what you seem to have, would be to use DAO to achieve what you want.


Also, I wouldn't advise using text fields as primary keys. i.e. Genre to Genre (in DVD table). It's always advisable to use an Autonumber as it takes up less space and memory.

And be wary of any code that says: DoCmd.DoMenuItem..... as that is obsolete code. Nowadays, we use DoCmd.RunCommand acCmd... syntax. You have the former example on your delete form.
 

Mile-O

Back once again...
Local time
Today, 10:10
Joined
Dec 10, 2002
Messages
11,316
If you run a delete Query silently, you need this code on your button's Click event.

Code:
DoCmd.SetWarnings False
DoCmd.OpenQuery "MyDeleteQuery"
DoCmd.SetWarnings True
 

AngelicGuardian

Village Idiot
Local time
Today, 10:10
Joined
Apr 7, 2003
Messages
43
If you want I could post some pure code that would delete the record but it involves using the Database and Recordset Variables
 

Mile-O

Back once again...
Local time
Today, 10:10
Joined
Dec 10, 2002
Messages
11,316
AngelicGuardian said:
If you want I could post some pure code that would delete the record but it involves using the Database and Recordset Variables

Along with using DAO and ADO, I was wondering if students, when they hand in projects such as this one, have to justify/explain the code.

If this is the case then it may be that RecordSet objects may be beyond the call of duty.
 

a.sinatra

quik
Local time
Today, 02:10
Joined
Jan 10, 2004
Messages
262
Umm. Could you, im learning right now, and im still going to use my delete query cause thats what i know, but the code would be great
________
Z9
 
Last edited:

Mile-O

Back once again...
Local time
Today, 10:10
Joined
Dec 10, 2002
Messages
11,316
a.sinatra said:
Umm. Could you, im learning right now, and im still going to use my delete query cause thats what i know, but the code would be great

Here's a link to explain Recordset objects, DAO, and ADO for you.
 

Users who are viewing this thread

Top Bottom