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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to delete from a checked box?

Status
Not open for further replies.

Sugarmello

IS-IT--Management
Jan 3, 2011
20
0
0
CY
Hi,

I have the following code for a delete button:


Private Sub Command77_Click()
On Error GoTo Err_Command77_Click


DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Exit_Command77_Click:
Exit Sub

Err_Command77_Click:
MsgBox Err.Description
Resume Exit_Command77_Click

End Sub

The question is how to delete from a checked box?
For example if there is a new patient the box will be checked. So when i want to delete all the new patients?
I understand that the code is where DOcmd and that in general coding is : if checked do so... but i have no idea of access code and which names should be used.

Thanks.
 
Me. the name of the checkbox=True

Would that be an answer?
 
When you say 'all' of the new patients do you mean the single record you are viewing or all that are checked in the underlying table

HTH << MaZeWorX >> "I have not failed I have only found ten thousand ways that don't work
 
I mean all the checked in the underlying table!
 
Is the checkbox value written to the table? If so then just use a delete query using the checkbox value(=true) as criteria for the query

HTH << MaZeWorX >> "I have not failed I have only found ten thousand ways that don't work
 
THanks

I will try that and see if it works.

Cheers.
 
I ve tried that before but I forgot that doesn't work .

I have created the delete query but when i try to assign that query to a command button. Access does not allow that.
So what do I have to do?
 
when i try to assign that query to a command button. Access does not allow that.

Can you show the code you have on the command button?


Randy
 
I didn't use any code!
I ve just used the command button and then followed the options!
I can link a button to run a query but it doesnt run delete queries!

That's why Iam asking for a solution.
 

OK, how did you try to create it?
Access certainly does allow delete queries to be run from a command button.


Randy
 
In the properties of the command button look for OnClick Event select Event Procedure and click the small box to the right od it to open the forms module add this code modifying it where you need to. Just below the first existing line and above 'End Sub' Should look like this

Private Sub YourButtonName_Click()
DoCmd.SetWarnings False 'turns access warnings off - remove if you want
DoCmd.OpenQuery("Add your query name here")
DoCmd.SetWarnings True 'turns access warnings on
End Sub




HTH << MaZeWorX >> "I have not failed I have only found ten thousand ways that don't work
 
btw sounds like you used the wizard to create the cmd button if so when it opens hit cancel and follow the above inst.

HTH << MaZeWorX >> "I have not failed I have only found ten thousand ways that don't work
 
Thank you!

I' ll try that and see if I'll have any problems.


Thanks.
 
Sugarmello,

MazeWorX' code and methods mentioned should be just the ticket for what you're talking about, so long as the query is written correctly, and so long as you are sharing the correct/complete story on this one.

Please do post back to verify whether this works out or not. If it does not work out, please post any error messages, or as much of a description of what is happening as you are able.

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top