Subform query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • solargovind
    New Member
    • Mar 2007
    • 41

    Subform query

    Hi,

    Can anybody suggest me how to call Subform/Main form's control in query...?

    For example, I have Two combo box in Mainform.

    If i select Student_roll_No in one combo box, in other combo box i need to display their marks,total,gra de etc., which has been called by query. This combo box has 7 coloumn heads which can display all the details.

    How could i display 2nd combobox query list based on the first combo box..?

    Assume the above case..
    - If the 2nd combo box is in Main form.
    - If the 2nd combo box is in Sub form.

    Pls.suggest me.

    Thanks in advance.

    ngr.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    To refer to controls on subforms, the format is:
    Code:
    [b]Within VBA Code[/b]
    Me.SubformControl.Form.ControlName
    
    [b]Absolute Path[/b]
    [Forms]![MainForm]![SubformControl].Form.ControlName

    Comment

    • JConsulting
      Recognized Expert Contributor
      • Apr 2007
      • 603

      #3
      in the after update event of combo 1, using whatever field you use to link the records (I used ID below) also, this assumes that ID is column(0) in combo 1 and it numeric

      dim strSQL as string
      strSQL = "select * from yourtable where ID = " me.combo1

      if combo2 is on the same form

      me.combo2.rowso urce = strSQL

      if combo2 is on a subform

      me.subformname. form.combo2.row source = strSQL

      J

      Comment

      Working...