Results 1 to 7 of 7
  1. #1
    NikoTheBowHunter is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2017
    Posts
    58

    How to delete certain fields in record on button press

    On my form at the top, drop down list, select the record and it populates the below fields with that records data. In this form, I have a section where I would like to create a button to clear only those fields. How would I accomplish this, coding/macro??? Obviously I need to a new button to clear these fields, but how would I code that button to clear only the fields I specify? Table/form/Field names are as follows:

    {Table: Inventory}
    {Form: Update Inventory}
    [1234 Requested] = yes/no
    [Date 1234 Requested] = date/time
    [1234 Received] = yes/no
    [First Name] = text
    [Reg#] = number



    Not all fields will always have data, sometimes only a couple of the fields will be completed. If someone could write the code for this or give me an example of the code so I can tweak it to work for my database it would be much appreciated.

    Cheers.

  2. #2
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    Just set them all to null. On the OnClick of the button:
    Me.[1234 Requested] = null
    Me.[Date 1234 Requested] = null
    ...

    Tip: Don't use spaces or special characters in names. So would be 1234_Requested or Date_1234Requested, etc.

  3. #3
    NikoTheBowHunter is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2017
    Posts
    58
    Quote Originally Posted by Bulzie View Post
    Tip: Don't use spaces or special characters in names. So would be 1234_Requested or Date_1234Requested, etc.
    This is my first and probably only database I will ever set up. As such, why is it important not to have spaces in the field names? Is it just to help with coding or does the system sometimes dislike that extra space? And thank you for the help and tip!

  4. #4
    NikoTheBowHunter is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2017
    Posts
    58
    and that code worked perfectly for what I needed, thank you very much!

  5. #5
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    Yes best to not have spaces and special characters for coding mainly. Spaces you can get away with but special characters are used by Access for various things so best to avoid them. Usually I just use the words or an underline if I need space such as EmployeeNbr, Employee_Nbr, etc.

  6. #6
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 10 Access 2016
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    It is not always a good idea to delete data in a Relational Data Base. You would be better suited to add an archive/inactive field (Yes/No) and then in your reports or queries use this to filter out that data.

  7. #7
    NikoTheBowHunter is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2017
    Posts
    58
    its a single table database, basically just tracks which phone we assigned a user. When we get the phone back, the users info is cleared so it can be assigned to someone else. no records are being deleted, just the data in those specified fields in the one record.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 11-24-2014, 03:55 AM
  2. Replies: 1
    Last Post: 09-16-2014, 02:26 PM
  3. Replies: 3
    Last Post: 11-25-2012, 06:09 PM
  4. Press a button to combine two fields to open a PDF
    By Douglas Post in forum Programming
    Replies: 4
    Last Post: 02-11-2012, 02:02 PM
  5. Command button help - delete record
    By Zukster in forum Forms
    Replies: 0
    Last Post: 08-27-2009, 08:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums