Full Version: Delete Part of Record
UtterAccess Forums > Microsoft® Access > Access Forms
mccloudm
Hi everyone,
I have 5 fields in this table. ( Name/Location/Date/Serial/Stock) I want to create a button in the form to delete only Name/Location/Date from the table, but leave the serial and stock numbers. I am not to keen on setting up procedres in VB. Any thoughts?
Mike
theDBguy
Are you saying you want to delete the fields or the data?
mccloudm
Just the Data of the Fields. I Still want the Field to be Present, just the data in the fields of the record to be delete.
Sorry for the confusion.
theDBguy
No problem. And you want to do this in a form, correct? If so, you can code the button with something like:
e.ClientName = Null
Me. Location = Null
Me.TransactionDate = Null
Note: Name and Date are reserved words in Access. Consider changing the names of your fields.
Hope that helps...
mccloudm
This works Great. Thank you.
theDBguy
You're welcome. Good luck with your project.
mccloudm
I just thought of something that could make this a lot easier.
In the field Location, is where I put the location of the items I issued. Is there a way I can Query the location field, and the remove all the data like I just did? A exaple of this is "Work Room". Can I query the criteria "Work Room" and remove Name/Location/DTG (was called date) leaving Serial and Stock fields alone?
theDBguy
If you want to delete all the selected data for all the records with a particular location, you can use an UPDATE query.
Create a new query in design view and add your table. Drag the two fields you want to delete and add the location field. Under the location field, in the criteria row, type the name of the location enclosed in quotes.
Run the query to make sure that you are only affecting the records you intend to delete.
If everything is okay, uncheck the Show box under the location field and then change the query type from Select to Update. The next time you run the query, it should ask you if you want to update the records.
Make sure you create a backup of your database before you try something like that.
Hope that helps...
mccloudm
Thank you very much. Sorry it took so long getting back to you, but once again, I am the only one in the office when Chaos happens.
theDBguy
No problem. We're happy to help. sad.gif
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.