Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2003

    Unanswered: Opening a subform from combo box choice


    i am a little bit stuck as to the code required to open a specific subform on a form when i select the values in the combo box. what i mean is when i select nurses from the combo box i want to be able to display the nurses subform to add additional data and the same goes for the docotrs subform when i selected that from the combo box.

    i have seen am example here but as i am new to this i am not quiet following the example fully.

    can any one please give me some code that would do this i would have thought that afterupdate of the combo box i would then display the relevant subforms from there i understood that much. but as to where next is what i ma confused upon.

    Thanks Bekka

  2. #2
    Join Date
    Dec 2002
    Préverenges, Switzerland
    assuming you already have a subform control on frmMain (if not, drag frmNurse onto frmMain ).

    do not assume that the subform control name is the same as the name of the form object displayed in the subform control.

    check (and edit if you like) the control name by closing & reopening frmMain in design view then click once on the subform control area and check properties/other/name
    (lets assume this reads: theSubFormControlName).

    then in yourCombo _afterupdate()
    'switch the subform to suit user selection in the combo
    theSubformControlName.sourceobject = yourCombo.value

    ...assuming your combo has .value like "frmNurse" and "frmDoc" or whatever the names of the subform candidates are.

    currently using SS 2008R2

  3. #3
    Join Date
    Dec 2003

    this is how i think i need to open the subform following the user choice which is either doctor or nurse (subform tbldoctor, or tblnurse)
    a bit like the psudeo code below

    Private Sub Emp_Type_AfterUpdate()
    'If emptype = doctor Then
    'sub_form tbldoctor
    'Else: emptype = nurse
    'sub_form tblnurse
    'End If

    sorry but i couldnt follow your code can you see a way of making my code work.


Posting Permissions

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