Results 1 to 7 of 7
  1. #1
    Robeen is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596

    Clear all text boxes on a subform [Datasheet].

    Hi,



    I am using this code:
    Code:
    Dim ctlTextBox As Control
    For Each ctlTextBox In Me.Controls
        If TypeName(ctlTextBox) = "TextBox" Then
            ctlTextBox.Value = ""
        End If
     Next ctlTextBox
    to clear all text boxes on a Main Form.

    When I try the same code in the Form Load of the sub form - it says I can't assign a value to this object.

    I just want the Main Form and Sub Form textboxes to be empty when they both Load up.
    There is a selection combo box that will populate the main form and the sub form [Master-Detail] once a selection is made.

    Right now the main form has all empty textboxes but the subform datasheet is showing detail irrelevant records belonging to another master record and I want no data till a cmb box selection is made.

    Thanks!!

    Thanks!!

  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,850
    Then, I think you have a linkage problem or corruption.
    How are the Form/subform related? Typically Linkfields

  3. #3
    Robeen is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Sorry, I didn't explain comprehensively.

    The Form & sub form are working just fine in relation to each other.
    The records showing in the Detail Form to start with are the ones pertaining to the very first Master record that is loaded by default [but I subsequently "" that data out in Form Load].

    When the selection is made from the ComboBox - everything falls into place & the master-detail relationship works perfectly and the users will see exactly what they asked for.

    The 'problem' is that Users will be going in to select a particular set of Master records - each of which could have one or more detail records - and when the forms FIRST open up - they will be looking at some other data.
    I just want them to start with a clean slate - blanked out Master & Detail Forms.

    My Band-Aid fix for now is to hide the Detail Form to begin with - and only show it after I have re queried the Master form with the selection criteria.

    My question here is how to blank out fields in the sub[datasheet] form... if possible. I would really like to know.

    Another thought I had was to set the initial record source of the Detail Form to a query that will always return no data . . . ??

    Thanks!

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    I am confused. First you say subform shows records not related to main form then you say the links work properly.

    If links work, how can subform show data not related to the current main form record?

    Is the selection combobox UNBOUND? Must be if used to input filter criteria.

    Why would you not want subform to show records - why should it be blank if the main form shows existing record and there are related records?

    Is the subform in datasheet view?
    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.

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    This is normal....
    "When you open a form containing a subform, the subform and its records are loaded before the main form".

    See
    Order of events for database objects
    http://office.microsoft.com/en-za/ac...005186761.aspx

    Click on Order of events for forms and subforms
    Look for Working with subforms at the bottom of the page.


    How to fix/change this.....?????

  6. #6
    Robeen is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    I think I made it confusing - sorry.
    __________________________________________________ __________________________________

    Bottom line: How do I 'Blank out' everything that shows up in the Sub Form [Datasheet] when the Form Loads? That is my question.

    I want to start with a blank Main Form and a blank Sub Form.
    I have 'blanked out' the Main Form text boxes.
    I can't blank out the sub [datasheet] form... [so I am currently making it not visible].
    I need help blanking out the sub form in the same way that I blanked out the Main form.

    The goal is:
    The Form loads - with the sub form - but both of them show no data.
    The User makes a selection from the combo box - my code changes the Recordsource for the Main Form & makes the sub form visible - and now the Main and Sub forms both show what the User needs to see.

    __________________________________________________ _________________________________

    The Combo Box uses its Row Source to get a set of available Values to select from.
    When a value is selected, I have a SQL statement that I plug the selection text into and then I use the SQL and a Requery statement to change the Recordsource of the Main Form.
    Then [currently] I am making the sub form visible ... and it has all the rows pertaining to the record on the Main Form displayed in datasheet view.
    The Master and Detail forms are working as Access intends them to.
    The Combo Box is working correctly.
    __________________________________________________ _________________________________

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    Never done this but some possibilities:

    1. open main form to new record row.

    2. open main form filtered to a dummy id (0)

    3. subform RecordSource is blank, set it after selection from combobox

    4. unbound forms
    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. Clear check boxes
    By Derrick T. Davidson in forum Access
    Replies: 1
    Last Post: 05-24-2014, 03:02 AM
  2. Filter subform based on text boxes
    By lewis1682 in forum Programming
    Replies: 7
    Last Post: 08-21-2013, 11:09 AM
  3. Replies: 2
    Last Post: 04-24-2013, 11:52 AM
  4. Replies: 1
    Last Post: 10-28-2011, 01:57 PM
  5. Replies: 3
    Last Post: 10-01-2011, 02:21 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