Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Join Date
    Jun 2009
    Posts
    95

    Unanswered: How do I make subform blank by default?

    How do I make the default display of my subforms be blank instead of the first record?

    Thanks,
    CT

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    If you mean that you want the subform to open on a new record, you can try this:
    In the property wondow, set the value of the OnLoad property of the subform to: GoToNewRecord.

    Have a nice day!

  3. #3
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    If your subform is set to only to do data entry and you want the actual subform itself to be blank you would do this:

    ex:
    Forms!MyMainForm!MySubForm.SourceObject = ""
    ex:
    Forms!MyMainForm!MySubForm.SourceObject = "mySubFormName"
    Last edited by pkstormy; 07-22-09 at 02:29.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  4. #4
    Join Date
    Jun 2009
    Posts
    95
    Where do I put that at pkstormy?

    Thanks,
    Ct

  5. #5
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Why ignore Sinndho?!

    I think Sindho's answer actually matches your need. Use a go to new record command on the form's start up.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  6. #6
    Join Date
    Jun 2009
    Posts
    95
    Would it be possible for you to explain to me how to set the OnLoad to GoToNewRecord?

    One problem though, my subforms are used for display purposes only, adding and editing is disabled.

    Thanks,
    CT

  7. #7
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You don't need to: Open the properties window of the subform and set the value of the OnLoad property: GoToNewRecord.

    Have a nice day!

  8. #8
    Join Date
    Jun 2009
    Posts
    95
    How do I set it as GoToNewRecord? Is there additional coding? I do not have a macro named GoToNewRecord.

    I am working in Access 2000, maybe that has something to do with it?

    Thanks,
    CT

  9. #9
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You can:

    1) Create a macro:
    -Name: GotoNewRecord
    -Action: GoToRecord
    -Record: New
    2) Set the value of the OnLoad property of the subform to: GoToNewRecord
    (see attached file)

    Or:

    Type the following code in the Form_Open event of the subform:
    Code:
    Private Sub Form_Open(Cancel As Integer)
    
        DoCmd.GoToRecord acDataForm, Me.Name, acNewRec
    
    End Sub
    Have a nice day!
    Attached Thumbnails Attached Thumbnails Macro GoToNewRecord.JPG  

  10. #10
    Join Date
    Jun 2009
    Posts
    95
    I really really appreciate your help, and this completely works for my AddEdit form.

    However, I also have a form where adding and editing is disabled. Is there a way to make that subform blank when the main form opens?

    Thank you so much,
    CT

  11. #11
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome.

    Opening the form with additions forbidden (AllowAdditions = False) is in contradiction with going to a new record when opening the form. What do you want to do precisely?

    Have a nice day!

  12. #12
    Join Date
    Jun 2009
    Posts
    95
    What I would like to do is when the form opens, which contains two subforms with add/edit disabled, to not show the first record in the query that it pulls info from and only display information when the selection is made in a listbox.

    In essence, the subform be blank when the main form is opened and only display information when the listbox selected is made, triggering a requery in the subform.

    Does that make sense?

    Thanks again,
    CT

  13. #13
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Yes it's clearer like that.

    There are several methods to do that. For instance, you could leave the RecordSource property of the subform blank (you then have an unbound form i.e., a form that's not bound to any source of data). When you want the subform to display some data, dynamically build the SQL string that will be the datasource that will "feed" the subform and adjust the contents of the controls accordingly.

    Have a nice day!

  14. #14
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    See! Never ignore Sinndho

    Nice work once again Sinndho!
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  15. #15
    Join Date
    Jun 2009
    Posts
    95
    Hey, sorry for the late response,

    I was wondering if it would be possible for you to explain to me how to dynamically build the SQL string to set the recordsource of my subforms when a selection on a listbox is made?

    Thank you so much for helping,
    CT

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •