Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: Passing VBA Query results to a subform


Message #1 by "Scott Ng" <ng013@y...> on Fri, 26 Jul 2002 19:12:19
I am looking to create a form where a user can query the Access 97 DB with 
unbound txt boxes.  Once the user hits a command button, the query results 
will populate a subform where they user can double click the relevant 
record and the record will populate another form.

I have created the search form, subform, and a results form and set up the 
strSQL.

How should I proceed next?

I tried using this code
Forms!frm_Result.RecordSource = strSQL
Forms!frm_Result.Refresh

I get a msg saying that my subform is either not open or that it does not 
exist in the db.

Scott
Message #2 by "Amy Wyatt" <amyw@c...> on Mon, 29 Jul 2002 16:22:49
I am assuming that frmResults is the subform. Not knowing where your code 
is to create the SQL I will give two examples of what to try to get this 
to work. You have to access the parent and then the sub form to effect the 
subform.

If your code to the command button is in the parent form the following 
should work:
    Me.frm_Result.Form.RecordSource=strSQL

If the command button call a function outside the parent form then the 
following should work:
    Forms!frm_Parent!frm_Result.Form.RecordSource=strSQL
where frm_Parent is the name of the parent form.

Hope this helps.

Amy

> I am looking to create a form where a user can query the Access 97 DB 
with 
u> nbound txt boxes.  Once the user hits a command button, the query 
results 
w> ill populate a subform where they user can double click the relevant 
r> ecord and the record will populate another form.

> I have created the search form, subform, and a results form and set up 
the 
s> trSQL.

> How should I proceed next?

> I tried using this code
F> orms!frm_Result.RecordSource = strSQL
F> orms!frm_Result.Refresh

> I get a msg saying that my subform is either not open or that it does 
not 
e> xist in the db.

> Scott
Message #3 by John Fejsa <John.Fejsa@h...> on Tue, 30 Jul 2002 08:27:13 +1000
Rather then using 

                    Forms!frm_Parent!frm_Result.Form.RecordSource=strSQL

for parent form, you can use Parent keyword as in 

                    Me.Parent!frm_Result.Form.RecordSource=strSQL


>>> amyw@c... 30/07/2002 2:22:49 >>>
I am assuming that frmResults is the subform. Not knowing where your code 
is to create the SQL I will give two examples of what to try to get this 
to work. You have to access the parent and then the sub form to effect the 
subform.

If your code to the command button is in the parent form the following 
should work:
    Me.frm_Result.Form.RecordSource=strSQL

If the command button call a function outside the parent form then the 
following should work:
    Forms!frm_Parent!frm_Result.Form.RecordSource=strSQL
where frm_Parent is the name of the parent form.

Hope this helps.

Amy

> I am looking to create a form where a user can query the Access 97 DB 
with 
u> nbound txt boxes.  Once the user hits a command button, the query 
results 
w> ill populate a subform where they user can double click the relevant 
r> ecord and the record will populate another form.

> I have created the search form, subform, and a results form and set up 
the 
s> trSQL.

> How should I proceed next?

> I tried using this code
F> orms!frm_Result.RecordSource = strSQL
F> orms!frm_Result.Refresh

> I get a msg saying that my subform is either not open or that it does 
not 
e> xist in the db.

> Scott


  Return to Index