Connecting Tech Pros Worldwide Forums | Help | Site Map

Subform query

Member
 
Join Date: Mar 2007
Posts: 41
#1: May 2 '07
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,grade 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's Avatar
Expert
 
Join Date: Jan 2007
Location: California
Posts: 3,835
#2: May 2 '07

re: Subform query


To refer to controls on subforms, the format is:
Expand|Select|Wrap|Line Numbers
  1. Within VBA Code
  2. Me.SubformControl.Form.ControlName
  3.  
  4. Absolute Path
  5. [Forms]![MainForm]![SubformControl].Form.ControlName
  6.  
JConsulting's Avatar
Expert
 
Join Date: Apr 2007
Location: Houston
Posts: 601
#3: May 6 '07

re: Subform query


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.rowsource = strSQL

if combo2 is on a subform

me.subformname.form.combo2.rowsource = strSQL

J
Reply