Results 1 to 7 of 7
  1. #1
    zx3 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Aug 2011
    Posts
    47

    Unhappy How to populate subform with another criterion

    Hi all,



    I have this project Database1.zip which use a form to list individual salesperson's amount made in a specific time range, when enter a salesperson say "a" (a to e to choose from) then click search button, the salesperson's amount(s) will be listed. And when you click the date listed(click inside the box with the date), the sales journal on the same form are supposed to list the amounts made on that date regardless of salesperson.

    My problem is i can only populate the subform (sales journal) with just one line, not all the amounts made during the same date, please help.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Change the subform default view property to CONTINUOUS FORMS or DATASHEET.

  3. #3
    zx3 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Aug 2011
    Posts
    47
    Thanks ranman256 for your suggestion, but i got error return by this line
    Code:
    Me.Child17.Form.DefaultView = 1
    run-time error '2136':
    To change this property, open the form or report in design view
    is there other way to set the default view?

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Some properties need to be set before the form is opened. This may very well be one of those properties. In other words, even the On Load event may not be soon enough. If you were to attempt this via VBA you would probably have to open the subform in design view and hidden, then apply VBA code to adjust the default view, Save Changes and close the form. This type of VBA requires a full version of Access because this type of VBA will not work during Run Time.

    If you need the subform object to be available as a Subform and available in both DS view and Single Form view. Suggest creating two objects, one for each purpose.

  5. #5
    zx3 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Aug 2011
    Posts
    47
    Thanks ItsMe for your suggestions, could you explain more about this,
    If you were to attempt this via VBA you would probably have to open the subform in design view and hidden, then apply VBA code to adjust the default view, Save Changes and close the form. This type of VBA requires a full version of Access because this type of VBA will not work during Run Time.
    and this
    If you need the subform object to be available as a Subform and available in both DS view and Single Form view. Suggest creating two objects
    I think i got full version of Access and i m not good enough to get subform updated at runtime, please help with the steps and code.

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    You do not get to choose what code works during Run Time and what code does not. Either the functionality you request utilizes Run Time or it utilizes something else, like design interface or Design Time (requires full version).

    So, design your form. Design its default view property to Single Form. Save it. Make a copy by Right clicking the saved Form Object in the Navigation Pane. Paste your copy in the Navigation Pane. Give it a name. Open the copy( that has the new name) in Design View.

    Assign the Default View Property of the second form as Data Sheet view. Save it.

    Now, you have two form objects that can be used as subforms.

    Use one when you desire DS view. Use the other when you desire Single Form view.

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    A form can be opened in different modes but once it is open, cannot switch.

    DoCmd.OpenForm "formname", acNormal

    or

    DoCmd.OpenForm "formname", acFormDS

    This will not work with subform because it is the main form that is called to open.

    I expect ItsMe's suggestion for alternate subforms is the only way to change the display mode of subform once open. Code would set the subform container control ControlSource property.

    A compromise is Continuous View. Controls can be arranged to look like Datasheet or Single and can still scroll records.
    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. Len expression as criterion?
    By Duradel in forum Queries
    Replies: 3
    Last Post: 01-19-2014, 01:37 PM
  2. Adding Field Using Multiple Criterion
    By kkyork in forum Access
    Replies: 1
    Last Post: 06-06-2012, 01:48 PM
  3. Weird Query Results using Percentage criterion
    By david.semadeni in forum Queries
    Replies: 6
    Last Post: 04-09-2012, 10:59 AM
  4. Populate a subform with data
    By intransit2 in forum Forms
    Replies: 1
    Last Post: 03-06-2012, 07:33 PM
  5. Query criterion for today and the future
    By scoughlan in forum Queries
    Replies: 3
    Last Post: 01-16-2012, 07:28 PM

Tags for this Thread

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