A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Subform populated from combo boxes



 
 
Thread Tools Display Modes
  #1  
Old March 3rd, 2008, 07:23 PM posted to microsoft.public.access.forms
GoCoogs
external usenet poster
 
Posts: 11
Default Subform populated from combo boxes

Hello,

I have two combo boxes linked to two different tables (workers &
competencies). When the user selects the worker and the competency
then clicks a button I want the subform to populate from a third table
which contains the worker, the competency tested, the date tested, and
the result.

I have created a query that retrieves the information I want with
parameters setup to prompt for the worker and competency.

I want to feed the values of the combo boxes to the parameters in the
query and display the results in a subform.

The code I have does not work at all:

Private Sub Command8_Click()
Dim db As Database
Dim rs As Recordset
Dim qdfParmQry As QueryDef
Set db = CurrentDb()
Set qdfParmQry = db.QueryDefs("WorkerCompResults")
qdfParmQry("which worker do you want results for?") =
comboPharm.Value
qdfParmQry("which competency do want results for?") =
comboComp.Value
Set rs = qdfParmQry.OpenRecordset()

SubFormWorkerCompResults.Form.Recordset = rs

End Sub

SubFormWorkerCompResults is bound to the query WorkerCompResults and
the parameters prompting for worker and competency popup before the
main form opens. I've been working on this for several hours and am
close to pulling my hair out. Please help!

Thanks,
-Blake
  #2  
Old March 3rd, 2008, 07:44 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default Subform populated from combo boxes

Make certain that your parameter names

qdfParmQry("which worker do you want results for?") =
comboPharm.Value
qdfParmQry("which competency do want results for?") =
comboComp.Value

are exactly the same as in the query.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"GoCoogs" wrote in message
...
Hello,

I have two combo boxes linked to two different tables (workers &
competencies). When the user selects the worker and the competency
then clicks a button I want the subform to populate from a third table
which contains the worker, the competency tested, the date tested, and
the result.

I have created a query that retrieves the information I want with
parameters setup to prompt for the worker and competency.

I want to feed the values of the combo boxes to the parameters in the
query and display the results in a subform.

The code I have does not work at all:

Private Sub Command8_Click()
Dim db As Database
Dim rs As Recordset
Dim qdfParmQry As QueryDef
Set db = CurrentDb()
Set qdfParmQry = db.QueryDefs("WorkerCompResults")
qdfParmQry("which worker do you want results for?") =
comboPharm.Value
qdfParmQry("which competency do want results for?") =
comboComp.Value
Set rs = qdfParmQry.OpenRecordset()

SubFormWorkerCompResults.Form.Recordset = rs

End Sub

SubFormWorkerCompResults is bound to the query WorkerCompResults and
the parameters prompting for worker and competency popup before the
main form opens. I've been working on this for several hours and am
close to pulling my hair out. Please help!

Thanks,
-Blake



  #3  
Old March 4th, 2008, 02:43 PM posted to microsoft.public.access.forms
djf
external usenet poster
 
Posts: 30
Default Subform populated from combo boxes

I do something similar that maybe you can use. In your query that creates the
subform, put the combo box (or list box) fields as criteria. For example I
have a list box named lstAreaIV. I put this as criteria in a field in the
query named Work_Order_ID. On the criteria line of the query it looks like
this:

[Forms]![frmMenuIV]![lstAreaIV]

The list box contains a list of Work Areas. When the user chooses a value in
the list box it becomes the criteria for the query. In the On Change property
of the list box I put in me.refresh. This will populate the subform. From
posting on this board I've learned that using the After Update property
instead of on change may be more efficient, but they both work.

"GoCoogs" wrote:

Hello,

I have two combo boxes linked to two different tables (workers &
competencies). When the user selects the worker and the competency
then clicks a button I want the subform to populate from a third table
which contains the worker, the competency tested, the date tested, and
the result.

I have created a query that retrieves the information I want with
parameters setup to prompt for the worker and competency.

I want to feed the values of the combo boxes to the parameters in the
query and display the results in a subform.

The code I have does not work at all:

Private Sub Command8_Click()
Dim db As Database
Dim rs As Recordset
Dim qdfParmQry As QueryDef
Set db = CurrentDb()
Set qdfParmQry = db.QueryDefs("WorkerCompResults")
qdfParmQry("which worker do you want results for?") =
comboPharm.Value
qdfParmQry("which competency do want results for?") =
comboComp.Value
Set rs = qdfParmQry.OpenRecordset()

SubFormWorkerCompResults.Form.Recordset = rs

End Sub

SubFormWorkerCompResults is bound to the query WorkerCompResults and
the parameters prompting for worker and competency popup before the
main form opens. I've been working on this for several hours and am
close to pulling my hair out. Please help!

Thanks,
-Blake

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:47 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.