Page 1 of 3 123 LastLast
Results 1 to 15 of 40
  1. #1
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389

    How can auto delete sub form's blank row

    Hello to all of you,

    I have created an order booking program for a clothing store which has a
    There is a main form and a sub forms located in it. In the main form, customer related information is entered, while in the sub form, the shed and meter related to the cloths ordered are entered. The data of main form is entered in the gray offer table and the data of sub form is entered in the gray shade table.

    There are total four fields in the gray shade table, one is auto number, second is gray ID, third is shade and fourth is meter. The gray ID field is created for greyoffer table to table relation.

    1. I want that whenever a new order is entered, in addition to the shed and meter, a serial number field should also be shown temporarily in ascending order in the sub form.

    2. When the user open any old record in for editing and make any row empty by deleting shade and meter from any row in the sub form, then that empty row is unnecessarily shown in the print preview. I want that if the user deletes the data of any row from the sub form during editing, So that row itself should be removed from the table.

    Please give your suggestions.
    Thank you.

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Do not allow the data to be removed once entered. Make the user delete the record after confirmation.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by Welshgasman View Post
    Do not allow the data to be removed once entered. Make the user delete the record after confirmation.
    This will not solve the problem because even while entering a new record, the data of the row can be cleared by moving the cursor to the previous row.

  4. #4
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    You can put a Delete button in the detail area of the subform.
    When used it will ask for Confirmation of Deletion.
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Quote Originally Posted by deepaksharma View Post
    This will not solve the problem because even while entering a new record, the data of the row can be cleared by moving the cursor to the previous row.
    No, the data will be saved if you move to another row, next or previous.
    Last edited by Welshgasman; 12-02-2023 at 11:57 AM.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by Welshgasman View Post
    No, the data will be saved if you move to a another row, next or previous.
    You are right, the blank data row will be saved automatically with its autonumber entered.
    Is there any method that can be implemented in the BeforeUpdate or "move on next row" event of the sub form to delete the entire row if the data of special field of the current record in the sub form is not present in the row.

  7. #7
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by mike60smart View Post
    You can put a Delete button in the detail area of the subform.
    When used it will ask for Confirmation of Deletion.
    Thanks Mike your method is working can it be put in the code with the above condition mentioned by me. post #6

    You are right, the blank data row will be saved automatically with its autonumber entered.
    Is there any method that can be implemented in the BeforeUpdate or "move on next row" event of the sub form to delete the entire row if the data of special field of the current record in the sub form is not present in the row.

  8. #8
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2019
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Form validation is best done in the Forms Before Update event which can be cancelled if the validation fails using Cancel = True
    You might also need the line Me.Undo
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  9. #9
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    In the Before Update of the Subform you can validate the Record

    If Me.[data of special field] Is Null then

    Code to delete the record



    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  10. #10
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Quote Originally Posted by deepaksharma View Post
    You are right, the blank data row will be saved automatically with its autonumber entered.
    Is there any method that can be implemented in the BeforeUpdate or "move on next row" event of the sub form to delete the entire row if the data of special field of the current record in the sub form is not present in the row.
    You do not save it in the first place? :-(

    Hardly rocket science?

    That is what the beforeUpdate event of the form is for?

    https://www.access-programmers.co.uk...-and-2.324342/
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  11. #11
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Quote Originally Posted by mike60smart View Post
    In the Before Update of the Subform you can validate the Record

    If Me.[data of special field] Is Null then

    Code to delete the record



    Record would not be saved then Mike, so no option to delete?
    One would just stop it being saved with that event?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  12. #12
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by mike60smart View Post
    In the Before Update of the Subform you can validate the Record

    If Me.[data of special field] Is Null then

    Code to delete the record



    sorry but this is not working

  13. #13
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    What Code did you use?
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  14. #14
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Quote Originally Posted by deepaksharma View Post
    sorry but this is not working
    See post #11 as to why
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  15. #15
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    Yes you are right, stupid of me to use Delete
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

Page 1 of 3 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Auto Text Insert In To A Blank Field In A Form
    By HectorTheInspector in forum Forms
    Replies: 8
    Last Post: 01-20-2017, 06:52 PM
  2. Replies: 4
    Last Post: 01-04-2016, 07:30 AM
  3. Replies: 2
    Last Post: 03-19-2014, 04:51 PM
  4. Code to delete the blank rows
    By drunkenneo in forum Programming
    Replies: 3
    Last Post: 02-17-2014, 09:26 PM
  5. delete record if 2 fields are blank
    By rlsublime in forum Access
    Replies: 1
    Last Post: 06-20-2012, 01:58 PM

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