Results 1 to 11 of 11
  1. #1
    Join Date
    Aug 2003
    Posts
    160

    Unanswered: Combobox Subform Question

    Hi! I got one combobox for selecting workorder type. Based On the workorder type I want to Display a subform on a main form.

    Main Form is going to be the same, but subform has to be changed.

    Any Ideas!

    Thanks
    Vad

  2. #2
    Join Date
    Sep 2003
    Location
    T.O.
    Posts
    326
    Have the subform hidden and requery it on the After_Update event of the combo box. I'm assuming the subform linked data involves the combo box.
    All code ADO/ADOX unless otherwise specified.
    Mike.

  3. #3
    Join Date
    Aug 2003
    Posts
    160
    Actually I am selecting Combobox value from a form other than these two main and subforms.

    I am selecting from From1.
    There is one main form called Form2 and there is a subform in it called Subfrom2.

    If I select it from Form1, I want to change the Subform2.

    Thanks.

    Originally posted by HomerBoo
    Have the subform hidden and requery it on the After_Update event of the combo box. I'm assuming the subform linked data involves the combo box.
    Vad

  4. #4
    Join Date
    Sep 2003
    Location
    T.O.
    Posts
    326
    Unless you actually take the time to update both a form and a resident subform to align, they need to be linked. You may want to consider Form1's combo box AfterUpdate event changing something on Form2, then requerying SubForm2. I have not gone through this sort of requirement before, so I may not be able to provide much help.
    All code ADO/ADOX unless otherwise specified.
    Mike.

  5. #5
    Join Date
    Aug 2003
    Posts
    160
    Hi! Idon't want to chenage the information in the subform, rather I want to chenge the subform based on the combobox selection in form1. This combox selection will reflect in form2 (lets say workordertype "PCRepair") as textbox. based on this textbox value which is "PCRepair" corresponding subform has to display.

    Thanks


    Originally posted by HomerBoo
    Unless you actually take the time to update both a form and a resident subform to align, they need to be linked. You may want to consider Form1's combo box AfterUpdate event changing something on Form2, then requerying SubForm2. I have not gone through this sort of requirement before, so I may not be able to provide much help.
    Vad

  6. #6
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    you want to change the subform?
    or update the contents of the same subform?

    changing the (from the parent form) subform is
    Me!subFormControlName.sourceobject = theNewSubformToDisplay

    subFormControlName & theNewSubformToDisplay need to reflect your reality of course.

    izy


    OOOPS!
    Me!subFormControlName.sourceobject = "theNewSubformToDisplay"
    Last edited by izyrider; 12-05-03 at 14:20.
    currently using SS 2008R2

  7. #7
    Join Date
    Aug 2003
    Posts
    160
    Let me explain clearly for you.

    Form1 has combobox to select WorkOrderTypes.

    Form2 has Subform Called Subform2. and Form2 Also has a text box to display the Combobox selection in Form1.

    Based on the text box value Subform2 has to change. There may be 5 or 6 Subforms. And also I want the Main Form, Subform connected whichever form is selected.

    IN the code you provied what I have to keep for"subFormControlName"

    The code also seems to be hardcoded.
    Need more explanation please let me know.

    Thanks.

    Originally posted by izyrider
    you want to change the subform?
    or update the contents of the same subform?

    changing the (from the parent form) subform is
    Me!subFormControlName.sourceobject = theNewSubformToDisplay

    subFormControlName & theNewSubformToDisplay need to reflect your reality of course.

    izy


    OOOPS!
    Me!subFormControlName.sourceobject = "theNewSubformToDisplay"
    Vad

  8. #8
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    looks like .sourceobject is what you need.

    you already have "5 or 6 subforms": here i will call them frm2sub1, frm2sub2, ...frm2sub6

    in designview of Form2, you have dragged any one of your subforms into Form2 so you now have a subform control on Form2.

    Access will have made the (stupid!!) decision to call this subform control the same name as the name of the subform you dragged in - strongly recommend you change this to avoid the confusion of having the subform control with the same name as one of it's potential sourceobjects:
    in form2 design view, click once on the subform control and look at
    properties/other/name.
    CHANGE this subform control name to something "neutral" like Form2subCtl
    save.

    the code:

    select case Forms!Form1.myCombo
    case this 'replace "this" with first combo value
    forms!frm2!Form2subCtl.sourceobject = "frm2sub1"
    case that 'replace "that" with second combo value
    forms!frm2!Form2subCtl.sourceobject = "frm2sub2"
    case whatever 'replace "whatever" etc
    forms!frm2!Form2subCtl.sourceobject = "frm2sub3"
    'etc
    end select

    will switch the subform.

    you need to find an event to trigger this code. Possibilities include _afterupdate on the combo in Form1, _load of Form2, etc


    if the code is in Form1 replace
    Forms!Form1.myCombo
    with
    myCombo

    if the code is in Form2 replace
    forms!frm2!Form2subCtl.sourceobject
    with
    Form2subCtl.sourceobject
    and if Form1 will not be open, also replace
    Forms!Form1.myCombo
    with
    theForm2textBox

    ok?

    izy
    currently using SS 2008R2

  9. #9
    Join Date
    Aug 2003
    Posts
    160
    Hi! Izy,

    I was kind of sick this weekend so I didn't come to work. I will work on this and if there are any problems I will let you know.

    Here is the code you sent:

    select case Forms!Form1.myCombo
    case this 'replace "this" with first combo value
    forms!frm2!Form2subCtl.sourceobject = "frm2sub1"
    case that 'replace "that" with second combo value
    forms!frm2!Form2subCtl.sourceobject = "frm2sub2"
    case whatever 'replace "whatever" etc
    forms!frm2!Form2subCtl.sourceobject = "frm2sub3"
    'etc
    end select

    My queston is:

    select case Forms!Form1.myCombo
    case this 'replace "this" with first combo value

    Here for this case statement instead of this we have to write the combobox value, which is for example "PC Repair"

    So here we are hard coding the combobox value. How some other people using the same application want to change the combobox values.

    Any Ideas


    Thanks for replying so patiently and clearly for this poor access guy.

    Thanks
    Vad


    Originally posted by izyrider
    looks like .sourceobject is what you need.

    you already have "5 or 6 subforms": here i will call them frm2sub1, frm2sub2, ...frm2sub6

    in designview of Form2, you have dragged any one of your subforms into Form2 so you now have a subform control on Form2.

    Access will have made the (stupid!!) decision to call this subform control the same name as the name of the subform you dragged in - strongly recommend you change this to avoid the confusion of having the subform control with the same name as one of it's potential sourceobjects:
    in form2 design view, click once on the subform control and look at
    properties/other/name.
    CHANGE this subform control name to something "neutral" like Form2subCtl
    save.

    the code:

    select case Forms!Form1.myCombo
    case this 'replace "this" with first combo value
    forms!frm2!Form2subCtl.sourceobject = "frm2sub1"
    case that 'replace "that" with second combo value
    forms!frm2!Form2subCtl.sourceobject = "frm2sub2"
    case whatever 'replace "whatever" etc
    forms!frm2!Form2subCtl.sourceobject = "frm2sub3"
    'etc
    end select

    will switch the subform.

    you need to find an event to trigger this code. Possibilities include _afterupdate on the combo in Form1, _load of Form2, etc


    if the code is in Form1 replace
    Forms!Form1.myCombo
    with
    myCombo

    if the code is in Form2 replace
    forms!frm2!Form2subCtl.sourceobject
    with
    Form2subCtl.sourceobject
    and if Form1 will not be open, also replace
    Forms!Form1.myCombo
    with
    theForm2textBox

    ok?

    izy
    Last edited by vad; 12-09-03 at 12:09.
    Vad

  10. #10
    Join Date
    Aug 2003
    Posts
    160
    Hi! Izy,

    Do you think all the subforms, I already have on the main form ie, Form2. I have only one subform on Form2. I need to create 3 more subforms. How can I link all the subforms to the main form. Do I need to place all the subforms on the Form2 inorder to get a form based on the combobox selection in Form1.

    And one more thing is in the code you have given what is "Form2subCtl" and I think "frm2sub2" is the name of the subfrm2 on Form 2.



    Thank u

    Originally posted by vad
    Hi! Izy,

    I was kind of sick this weekend so I didn't come to work. I will work on this and if there are any problems I will let you know.

    Here is the code you sent:

    select case Forms!Form1.myCombo
    case this 'replace "this" with first combo value
    forms!frm2!Form2subCtl.sourceobject = "frm2sub1"
    case that 'replace "that" with second combo value
    forms!frm2!Form2subCtl.sourceobject = "frm2sub2"
    case whatever 'replace "whatever" etc
    forms!frm2!Form2subCtl.sourceobject = "frm2sub3"
    'etc
    end select

    My queston is:

    select case Forms!Form1.myCombo
    case this 'replace "this" with first combo value

    Here for this case statement instead of this we have to write the combobox value, which is for example "PC Repair"

    So here we are hard coding the combobox value. How some other people using the same application want to change the combobox values.

    Any Ideas


    Thanks for replying so patiently and clearly for this poor access guy.

    Thanks
    Vad
    Vad

  11. #11
    Join Date
    Dec 2003
    Posts
    13
    i have been trying to do something similar for the past couple of hours and am having trouble going through this example and applying it to my own.

    i have an employees for with two subforms, nurses and doctors. on the employees form which is the main form on which i have a combo box with two choices either doctor or nurse so which ever is selected when entering data i want it to display the relevant form. i can see from the example you where using a select case statement which to me makes sense in the sense that which ever is selected the relevant subform should appear and the non relevant subform should hide.

    i am unsure as to the control which access has and what is relevant to the forms.

    can any one give me a clear set of instructions. i have already created the employee form and put on the doctor and nurse subform.

    advice needed

    Bekka

Posting Permissions

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