Results 1 to 11 of 11
  1. #1
    5 Star Lounger
    Join Date
    Oct 2001
    Location
    San Bernardino, California, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Subforms (XP & 97)

    I have a main form (Job Entry) that has a number of fields. One of these fields is "Job Type". I would like my job entry form to display one of several subforms depending on what is input (from a combo box) in the "Job Type" field. Is this possible? If so, how? The rationale is that different job types have different data elements I would want to enter or view.

  2. #2
    3 Star Lounger
    Join Date
    May 2002
    Location
    Toronto, Ontario, Canada
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subforms (XP & 97)

    Sure... Just off the top of my head I think you could do something like...

    - Open the Job Entry form with the subform control invisible
    - Let the user select a value from the combobox
    - Once the value is chosen, have a Select Case in the event procedure with each of the proper recordsource names by type...
    - Reset the recordsource for the subform accordingly and make it visible...
    Or
    - You could use the subform name in the Select Case and change the subform control Source Object according to type.....

    These are just ideas... If you need more specific instructions, post back...
    HTH

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Subforms (XP & 97)

    If different job types have different data elements, you could create a subform for each type. On the main form, create a tab control. Put each subform on its own page of the tab control. You now have two possibilities:

    - Let the user select the job type by clicking the appropriate tab, or
    - Make the tabs invisible by setting the Style property of the tab control to None. Select the appropriate tab in code in the AfterUpdate event of the combo box, by setting the value of the tab control; the value is zero-based, so setting the value to 0 selects the first tab page, etc.

  4. #4
    5 Star Lounger
    Join Date
    Oct 2001
    Location
    San Bernardino, California, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subforms (XP & 97)

    Hans, I like the idea of using tabs. I added a tab control but it shows up as a small box with two tabs... I have already created the subforms, how do I add then to the tab pages? Also, How do I make the tabs appear at the top of the main form instead of a small box inside the main form? See the attached picture for what I am talking about.
    Attached Images Attached Images

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Subforms (XP & 97)

    To place a subform on one of the tab pages:
    - Select the subform.
    - Cut it to the clipboard (Ctrl+X).
    - Click on the desired tab page.
    - Paste the subform (Ctrl+V).
    - Repeat until all subforms have been placed.
    - Select the tab control by clicking in the blank part immediately to the right of the last tab, then move it to the desired position and resize it to the preferred size.

    You can set the Caption property of each of the tab pages to something meaningful.

  6. #6
    5 Star Lounger
    Join Date
    Oct 2001
    Location
    San Bernardino, California, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subforms (XP & 97)

    Okay, thank you - so far no success. When I did that I had two undesired results:
    1) They still appeared as a tabbed box on my main form when I wanted to only see the tabs at the top and not see the subform until I selected the tab - then the mainform would be replaced by the subform.

    2) I was unable to enter data

    I suspect I don't have it set up right in terms of subform relationship. All the forms are based on tables and all three tables involved share a common field - job_Number. I set up a one-to-many relationship between the job_number fields on the job table and each of the other two tables.

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Subforms (XP & 97)

    1. In a tab control, there is always one visible/active page. If you want all subforms to be hidden until a choice is made, a tab control is probably not the ideal way to do it.

    2. A tab control doesn't influence whether you can enter data in a subform or not; it is only a container used to organize controls in a convenient way.

  8. #8
    5 Star Lounger
    Join Date
    Oct 2001
    Location
    San Bernardino, California, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subforms (XP & 97)

    I was wrong about not entering data - I fixed that.

    The effect I was looking for was to have a form with three tabs at the top - like index cards. The first tab (for the main form) would say jobs, the second & third tabs wouls have appropriate captions. Maybe I misunderstand the subform concept but I have this type of multi-tab construct in other Access applications and I like the appearance.

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Subforms (XP & 97)

    What you want should be possible; just put the 'main form' controls in the first tab page, and the subforms on the subsequent tab pages. Move and resize the tab control to cover the entire Detail section of the form.

  10. #10
    5 Star Lounger
    Join Date
    Oct 2001
    Location
    San Bernardino, California, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subforms (XP & 97)

    Thank you - that works. However, I have one subform in datasheet view and I notice that it does not display any header. I am trying to distinguish on the datasheet view data elements associated with the job input and the job output. I was hoping to somehow be able to either use headings or colors to show the difference. What would you suggest. Below is an approximation of what I want (dots & dashes used only for spacing in this post - I can seem to use spaces or tabs). The INPUT & OUTPUT are the headers I want - the other field names (labels) are done automatically in datasheet view.

    .......................INPUT>>>-------------------->>>OUTPUT
    Line#... Medium Density tape#....... Medium Density Tape#

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Subforms (XP & 97)

    A (sub)form in datasheet view doesn't display a form header or footer. If you create a continuous form with more or less the same layout as as the datasheet, you can display a form header with the desired labels. Otherwise, move the subform down a bit and put the extra labels on the tab page above the subform. The disadvantage of a datasheet is that the user can change the column widths; the positiion of the labels won't change.

Posting Permissions

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