Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete a single record by selection? 1

Status
Not open for further replies.

Turb

Technical User
Feb 11, 2003
154
US
Hi all!
I have a Acc2000 database running with the main window hidden and all forms 'pop-up'.
I have one form, based on a query, that is giving me troubles with record deletion.

Before going to the hidden window setup, my users could simply use the 'record selecters' of the form and right click/cut to delete a specific record. This no longer works (selection seems to work, but the cut/copy/paste dialog is no longer visible).
Since going back to a non-hidden window is not an option, I was wondering if anyone could help me out.

How can I take an SQL statement, under a command button, like this partial one
Code:
DoCmd.RunSQL "DELETE * FROM LocTemp WHERE ItemNumber [b][blue]?????[/blue][/b];"
and make the 'where' statement indicate the selected record of the currently open form?
Something like this:
Code:
DoCmd.RunSQL "DELETE * FROM LocTemp WHERE ItemNumber = [Me]![[b][blue]SELECTED RECORD[/blue][/b]]

Thanks in advance!


- Turb
 
Code:
DoCmd.RunSQL "DELETE * FROM LocTemp WHERE ItemNumber =" &  [Me]![NameOfControlOfThePk]
 
pwise,
Thank you for your response!

Wouldn't this
Code:
DoCmd.RunSQL "DELETE * FROM LocTemp WHERE ItemNumber =" &  [Me]![ItemNumber]
want to delete ALL the records with the same "ItemNumber" showing on the form, not just a single selected record?


- Turb
 
I tried the code
Code:
DoCmd.RunSQL "DELETE * FROM LocTemp WHERE ItemNumber =" &  [Me]![ItemNumber]
and got an error stating "Microsoft Access can't find the field 'Me' referred to in your expression".
I also tried the code
Code:
DoCmd.RunSQL "DELETE * FROM LocTemp WHERE ItemNumber =" & [Forms]![ModifyPartLocation]![ItemNumber]
and got this error:
"Syntax error (missing operator) in query expression 'ItemNumber = 100.7520.24A'".

Thanks!


- Turb
 
Oh geez... [blush]
How this for ignorance:
Who needs a command button?
All the user has to do is click the recordselector of the record to delete and hit the 'delete' key on his/her keyboard!!!

*sigh*
Why is it we sometimes want make things so simple they're hard??

Thanks!


- Turb
 
Code:
DoCmd.RunSQL "DELETE * FROM LocTemp WHERE ItemNumber=[!]'[/!]" & Forms!ModifyPartLocation!ItemNumber [!]& "'"[/!]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top