Results 1 to 5 of 5
  1. #1
    eagerlearner is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2014
    Posts
    3

    Deleting Form and Controls in VBA


    Good day everyone,

    I would like to create VBA code which will be triggered byon-click event of a button on Form-A. Code should be able to do any one of thefollowing, whichever is easy.

    Option 1:

    1. Deleteall the controls on a form “POStatsFinal”
    2. Createfive text box controls with names box1, box 2, box 3, box 4 and box 5 on “POStatsFinal”

    Option 2:

    1. Deletea form “POStatsFinal”
    2. Createa new form and name it “POStatsFinal”
    3. Createfive text box controls with names box1, box 2, box 3, box 4 and box 5 on “POStatsFinal”

    Your help will be greatly appreciated.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Please describe the "business rationale" that would use this proposed solution in plain English.
    Rarely have I seen a need to delete a Form (with its controls) during operation of the database.

    A Form is basically a means of displaying data that is stored in a table. The Form has a Recordsource (table or query or other) and the data in this Recordsource can be displayed in Controls on the Form. By moving to the next record in the Recordsource, the new data values are displayed in the Controls. (This is the mechanism for bound Forms).

  3. #3
    eagerlearner is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2014
    Posts
    3
    I have one form which calculates some parameters during on load event and I am displaying results of those calculation on this form using text boxes. This form is hidden. Using this approach, query which uses these five values from the hidden form runs at very good speed. If I calculate these five parameters when query is running the query takes exponentially long time to run.

    In addition, the number of text boxes on the hidden control depends upon the number of contractors my project will have. If there are three contractors on a project then I would like to have three text boxes on the hidden form and so on. I hope this gives you little bit more to understand my request.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Please show the form and sample calculations.
    You may get some ideas this link where multiple instances of a form are used.

    You could try the deleteObject see: http://msdn.microsoft.com/en-us/library/office/ff197376%28v=office.14%29.aspx



  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    A textbox for each contractor? Sounds like non-normalized data structure.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. inserting/deleting field in form by vba
    By joshynaresh in forum Forms
    Replies: 5
    Last Post: 09-14-2014, 04:06 PM
  2. Deleting data from a report using form
    By LonnieCAR in forum Access
    Replies: 9
    Last Post: 03-27-2014, 07:48 AM
  3. Deleting records on a form using VBA
    By lawdy in forum Programming
    Replies: 5
    Last Post: 05-06-2013, 06:06 PM
  4. Deleting The Sub-Form Record From Main Form
    By vdanelia in forum Forms
    Replies: 0
    Last Post: 11-08-2011, 04:33 PM
  5. Replies: 11
    Last Post: 12-14-2010, 01:25 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