Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Join Date
    May 2012
    Posts
    64

    Unanswered: fields only become visible once option is selected in form

    I have an extensive form with multiple tabbed pages and subforms in it that all correlate to one patient. I want the user to be able to select an option under the diagnosis combobox and then related fields appear on the form. For example, if stroke is selected, all fields related to stroke will then be visible. If headache is selected, then all fields related to headache will be visible. It won't work to have them greyed out as there will be about 30 possible diagnoses all with different fields.

    What would be the best way to do this? I know you could use a pop up form but my client has made it clear that she doesn't want this.

  2. #2
    Join Date
    Aug 2004
    Location
    Cary, NC
    Posts
    264
    I've done something similar before by using a tab control. You just hide the tab strip and move between the tabs in code based on their selection in the combo box. It's a clean looking solution since the tab control is invisible to the user and each diagnosis page can be designed independently. But it may not work if your design contains multiple tabbed pages and subforms already. Any way to simply that or consolidate the fields that change?

    You can also just use the visible attribute on the existing controls to show or hide them, but it's harder to manage in my opinion.

    Steve

  3. #3
    Join Date
    May 2012
    Posts
    64
    No, there really are too many fields to consolidate it all to one tab. Could I place a subform in my form that is invisible until a selection is picked and then it becomes visible? and could I place several of these forms on top of each other? If so, how do I make something invisible until a selection is chosen?

  4. #4
    Join Date
    Aug 2004
    Location
    Cary, NC
    Posts
    264
    Quote Originally Posted by klpe237 View Post
    No, there really are too many fields to consolidate it all to one tab. Could I place a subform in my form that is invisible until a selection is picked and then it becomes visible?
    I don't understand why you think you can fit your fields on a subform but not on a tab. You can make a tab page as big as a subform.

    Quote Originally Posted by klpe237 View Post
    and could I place several of these forms on top of each other? If so, how do I make something invisible until a selection is chosen?
    Of course you can have multiple forms stacked on top of each other, it just becomes difficult to manage. This is why I suggested a tab control. You use a separate tab page for every diagnosis, just like you are for subforms, but the tab control is easier to manage. The trick is to leave the tabs visible during design so you can flip through the tabs at will, then when the form is opened add a statement to hide the tabs from the user:

    tabControlName.Style = 2

    When a specific diagnosis is chosen you simply move to that tab:

    tabControlName.Pages("headache").SetFocus

    ---

    If you really want to use subforms you can hide and unhide them with something like this:

    Forms![ParentFormName]![SubformName].Visible = true

    or to create a toggle to hide it if it's visible and show it if it's hidden:

    Forms![ParentFormName]![SubformName].Visible = Not Forms![ParentFormName]![SubformName].Visible

    Steve

  5. #5
    Join Date
    May 2012
    Posts
    64
    Can I add tabbed navigation within another tabbed navigation? There isn't a way to get rid of the navigation I currently have as there are just too many fields. However, if I can add a second tabbed navigation within one of my navigation pages and then make that second tabbed navigation invisible then it might work. Is it possible to do this?

  6. #6
    Join Date
    Aug 2004
    Location
    Cary, NC
    Posts
    264
    I'm not aware of any way to add a tab control directly to another tab, but you can create one subform and add the tab control to that. Use that subform to contain the tab control with all of the different tabs related to the different diagnosis types and insert the subform into one of the tabs on the main page.

    I would make sure to keep the tab strip hidden when the form is open or your interface is going to get very overwhelming

    Steve

  7. #7
    Join Date
    May 2012
    Posts
    64
    Okay, this definitely gives me a starting point! I'm assuming I use the visible property to hide the tab strip, but if I do this, will it not hide the forms inside too? And how will I hide all forms until an option is selected? And how do I link directly to a tab? Also, there could me multiple diagnoses, so how would I handle that? Or would I have a multiple item form and include the tabbed form in each form that is repeated?

    Sorry for the massive amount of questions, but I'm hoping for at least a starting point!

  8. #8
    Join Date
    Aug 2004
    Location
    Cary, NC
    Posts
    264
    Quote Originally Posted by klpe237 View Post
    I'm assuming I use the visible property to hide the tab strip, but if I do this, will it not hide the forms inside too?
    Use tabControlName.Style = 2 to hide the tab strip. Essentially sets the tab style to none.

    Quote Originally Posted by klpe237 View Post
    And how will I hide all forms until an option is selected?
    I guess the easiest way would be to have a tab page that is blank

    Quote Originally Posted by klpe237 View Post
    And how do I link directly to a tab?
    Getting to the controls on a tab is the same as any other control on the form, just reference it directly. To move between the tabs use:
    tabControlName.Pages("headache").SetFocus (Assuming that one of your tab pages is called headache)

    Quote Originally Posted by klpe237 View Post
    Also, there could me multiple diagnoses, so how would I handle that? Or would I have a multiple item form and include the tabbed form in each form that is repeated?
    I wouldn't try the multiple item form, that is just a maintenance nightmare. You could give the user a control to navigate between the diagnostic pages once they are chosen. The idea was to have one display at a time to simply the design and reduce clutter.

    Steve

  9. #9
    Join Date
    May 2012
    Posts
    64
    I wouldn't try the multiple item form, that is just a maintenance nightmare. You could give the user a control to navigate between the diagnostic pages once they are chosen. The idea was to have one display at a time to simply the design and reduce clutter.
    I don't think that will work. I want there to be a combo box, and in that combo box you select one diagnosis, like stroke. Once you select that, several additional fields appear to the right that deal with the type of stroke it was. Then I want the user to select another diagnosis like Aneurysm, and then have a different set of fields appear about the type of aneurysm and on and on.

    If I only had one diagnosis, then what you are suggesting would work, but I can't include my tabbed page in a continuous form, Access doesn't allow it. Right now, I have a tabbed page for aneurysm, stroke, etc... but the client wants these all on one page. I have considered having the subforms relating to each diagnosis pop up when that option is selected, but then I don't know how to make this work you are reviewing a patient.

    When a patient is chosen, I need the user to be able to see all of their diagnoses and related information to them. I know this is complicated but I don't know how else to do it!

  10. #10
    Join Date
    Aug 2004
    Location
    Cary, NC
    Posts
    264
    You know how to show or hide controls and all the technical aspects of what you are looking to do. Your issue really comes down to how to design your form for the best user experience, and it doesn't sound like your current design is working. I would take some time to think through the use cases and data flow to see if a better design can be found.

    Steve

  11. #11
    Join Date
    May 2012
    Posts
    64
    Okay, I have rethought my design and changed my structure around a little bit so that it will work to use the hidden tabs. I'm still working through how to do it though.

    I have set my tab visible property to No which has made everything invisible since my first tab is blank. Above the tabbed pages I have a combobox. I'm assuming I need some type of statement saying Iff [combobox] = Aneurysm Then [tabbed page name].SetFocus. What would be the correct code to do this and where would I put it? In the onUpdate property of the combobox or on the tabbed page itself?

  12. #12
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    look at the super/sub type model for this
    I suspect you need a separate form for each type or group of diagnoses
    I'd rather be riding on the Tiger 800 or the Norton

  13. #13
    Join Date
    Aug 2004
    Location
    Cary, NC
    Posts
    264
    Quote Originally Posted by klpe237 View Post
    Above the tabbed pages I have a combobox. I'm assuming I need some type of statement saying Iff [combobox] = Aneurysm Then [tabbed page name].SetFocus. What would be the correct code to do this and where would I put it? In the onUpdate property of the combobox or on the tabbed page itself?
    Look at the previous posts for some code samples.

    As far as where to put it... the code needs to be triggered by a certain event, a change in value or a user input for example, so put the code to change tab pages in an event of the control that would trigger the change in tab pages (ie: the combo box)

    Steve

  14. #14
    Join Date
    May 2012
    Posts
    64
    I've gotten the code to almost work! Here is what I have used:
    Code:
    Private Sub Form_DataChange(ByVal Reason As Long)
    If Me!PDx.Value = "Aneurysm (acute ruptured)" Then
    Me.aneurysmSearch.SetFocus
    Me.aneurysmSearch.Form!ruptured.SetFocus
    End If
    End Sub
    PDx is the combobox I am using. aneurysmSearch is my form and ruptured is the first field in that form. It was working where I could click add diagnosis and a pop up form would just show the combobox where I choose the diagnosis. If a certain option was selected, then it would go to a specific tab where the form is now visible. The problem is that I want the add diagnosis button to send you to the form where you can click through the current diagnoses for that patient and then click another button that says add new to clear out the form so you can add another diagnosis for that patient.

    My problem is that if I don't set my form to data entry then when you click the add diagnosis button, it will show the combobox selection and then you can use the navigation buttons to click through the different diagnoses for that patient. This part works. However, the corresponding tab isn't being shown when I click through the diagnosses. I have added my code to almost all of the event options for the form and the combobox so that as you click through the different diagnoses records, the tabbed pages that are visible should be seen. However, it is staying on the first tab that is blank so none of the additional fields are ever seen.

  15. #15
    Join Date
    Aug 2004
    Location
    Cary, NC
    Posts
    264
    Have you tried using the forms On Current event? That should trigger as you are navigating through the diagnosis records. In that event you just need to call the method that changes your tab pages with the value of the current diagnosis.

    I'm confused if you are trying to move tabs or subforms though... Your code sample is setting the focus to the subform rather than changing tabs but earlier you said: "Above the tabbed pages I have a combobox." which leads me to believe that your additional fields are in tabs. If this is the case why are you setting the focus to the subform rather than just switching tabs?

    As a side note, if you need to have the tab changing code in multiple locations you should try to put it in a sub routine and call that whenever it is needed. Makes maintaining your code a lot simpler.

    Steve

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
  •