Results 1 to 8 of 8
  1. #1
    Star Lounger
    Join Date
    Mar 2004
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Enable Subform based on main form combo box (2003)

    I have found most of what I need on this website - but am getting more confused as I try to implement the slightly different scenarios - and none of what I've tried has worked.

    I have a main form [frmEPPt_History] with only a combo box on it. It is bound with the [EPPtHistoryID] but displays the column 2 Description that I wrote a SELECT statement for in the Row Source.

    I also have a subform [frmEPPt_Hist_DeviceSub] with only one text box on it called [Device].

    The text box (or subform?) should not be visible unless the main form combo box selection is one of either [HistoryID] 5, OR the Description "Cardiac Device".
    1. I am not sure if I should use the ID field or the Description.
    2. I am not sure which - the subform or the text field on the subform - should be disabled until they pick the item in the combo box that triggers it.
    3. I am also not sure of the code I need to write.
    Thanks so much,
    Vicky

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

    Re: Enable Subform based on main form combo box (2003)

    The value of the combo box is the EPPtHistoryID, so you have to look at that.
    I'd show/hide the subform.
    You can use the After Update event of the combo box for this:

    Private Sub ComboName_AfterUpdate()
    Me.frmEPPt_Hist_DeviceSub.Visible = (Me.ComboName = 5)
    End Sub

    where ComboName is the name of the combo box, and frmEPPt_Hist_DeviceSub should be the name of the subform as a control on the main form. This is not necessarily the same as the name of the subform in the database window. Open the main form in design view and click once (and only once) on the subform to select it; you'll see the name of the subform as a control in the Object dropdown on the toolbar, and in the title bar of the Properties window.

  3. #3
    Star Lounger
    Join Date
    Mar 2004
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Enable Subform based on main form combo box (2003)

    Well, I’ve been working on this all morning – but must still be doing something wrong –and have learned some things in the meantime.

    I was trying to make this work on a main (single form) with a subform with no success.
    But, in actuality – this main form will not be a single form so I am not sure that I can accomplish what I need to do with the previous request. (I did not know that you could not put a subform on a continuous form – but I do now)

    Here’s what I am trying to accomplish -and sorry for the confusion:

    I have a main patient demographic form.
    I have a subform on the main form that lists cardiac “History” (a combo box).
    One of the selections in the History combo box (Cardiac Device) requires further explanation – for which I had a subform on the subform - with another combo box for "Device Types". Not all of the History selections need this explanation – so I would like the Device Type (subform) hidden unless Cardiac Device is chosen in the list.

    The specifics look like this:

    -Patient Demographics (Name, Acct #... etc)
    -History (choose all that apply)

    CAD
    HTN
    Prior ablation
    Prior cardioversion
    Cardiac Device__________________(Device type)
    Pulmonary disease
    OSA
    Prior CVA/TIA
    DM
    What would be the best way to enter this data on a form?
    Or should I just add all of the device types to the History table?

    The table relationships are:
    Patient >Patient/History<History
    and
    PatientHistory>PatientHistoryDevice<Device

    Thank you,
    Vicky

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

    Re: Enable Subform based on main form combo box (2003)

    Could you post a stripped down copy of your database? See <post#=401925>post 401925</post#> for instructions.

  5. #5
    Star Lounger
    Join Date
    Mar 2004
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Enable Subform based on main form combo box (2003)

    Here it is - thank you for looking at it...
    Vicky
    Attached Files Attached Files

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

    Re: Enable Subform based on main form combo box (2003)

    See the attached version. There was a typo - Visable instead of Visible.

    I also added the code to the On Current event of the subform, so that the sub-subform is displayed/hidden as the user moves from record to record.
    Attached Files Attached Files

  7. #7
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Enable Subform based on main form combo box (2003)

    The specific reason you get an error is that you have spelt visible as visable in the after update event.

    There are multiple history records for each patients, and multiple devices for history records where historyID =5 ?

    You can have a subform in the form footer of a continuous form, so I have moved frmEPPt_Hist_DeviceSub2 to the footer of frmEPPt_HistorySub.

    Also the code in the after update event, needs to be repeated in the oncurrent event of frmEPPt_HistorySub.
    Attached Files Attached Files
    Regards
    John



  8. #8
    Star Lounger
    Join Date
    Mar 2004
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Enable Subform based on main form combo box (2003)

    Thank you both so much. It is perfect. I won't forget how to spell visible ever again :-)
    I learn so much from this site!
    Vicky

Posting Permissions

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