Report parameters from listbox

ajm

Registered User.
Local time
Today, 00:26
Joined
Oct 6, 2006
Messages
16
Hi
We have generated a query to produce us a report from our database. The parameter to that report is a Foreign Key in the main query table, and we would like to present it as a drop-down box from the table in which it is the primary key.
EG our query
"select * from Maintable where FK=[FKid];"
The secondary table -
FKid - Autonumber
Listitem - Text.
We need to have all the "Listitem" records in a dd box for the user to select, instead of them having to learn the Foreign Key id,

Anybody got any ideas ?
Many thanks in advance
ajm
 
Presuming the listbox is NOT multiselect, you can simply refer to it in your query:

select * from Maintable where FK=Forms!FormName.ListboxName

The FK would have to be the bound column of the listbox.
 
How to link them up

Hi
Thanks for that - I have made the changes to the Query as you suggested
SELECT *
FROM KeyDocuments
WHERE categoryid=Forms!Frm_KeyDocsByCategory.LB_Categories

and created a Listbox "LB_Categories" on the form - Frm_KeyDocsByCategory.

But I can't get the query to run when I select a category from my Listbox.
I guess that I need to link the two up somehow.
Anyone know how I can do that ?

Thanks
ajm
 
"can't get the query to run" implies that you tried something and failed. It would have helped if you'd posted what you tried, so we could sort it out. What I would do is run the report from a button, since users will inevitably click on the wrong selection occasionally, so I let them make a choice then click a button. The easiest way to do that is the button wizard.
 

Users who are viewing this thread

Back
Top Bottom