Query Combobox Problems

G

Guest

This is the code of my query:
SELECT Table.Column
FROM Table INNER JOIN Othertable ON Table.Column = Othertable.Column
WHERE (((Table.Column)=[Forms]![Formname]![cboname].[RowSource]))
ORDER BY Othertable.Column;

It's called by a list box in the same Form as the rowsource, it's meant to
populate said list. Now the problem I am having is, no matter what I do, the
moment I open the form it asks for the parameter instead of just taking it
out of the combobox, also I can't seem to get the listbox to run the query
again if I update the combobox. I've taken a look at some of the online help
but the solutions they give do not seem to work for me (partially because I
havn' found one yet using this method to populate a listbox)

Please help!

I am using Access 2003
 
G

Gary Walter

UnderSeven said:
This is the code of my query:
SELECT Table.Column
FROM Table INNER JOIN Othertable ON Table.Column = Othertable.Column
WHERE (((Table.Column)=[Forms]![Formname]![cboname].[RowSource]))
ORDER BY Othertable.Column;

It's called by a list box in the same Form as the rowsource, it's meant to
populate said list. Now the problem I am having is, no matter what I do,
the
moment I open the form it asks for the parameter instead of just taking it
out of the combobox, also I can't seem to get the listbox to run the query
again if I update the combobox. I've taken a look at some of the online
help
but the solutions they give do not seem to work for me (partially because
I
havn' found one yet using this method to populate a listbox)

You might be trying to do something out of my experience,
but I think you just want to get rid of ".[RowSource]" in your
query.

[Forms]![Formname]![cboname] will provide the value
of the bound column of your combo box...

SELECT Table.Column
FROM Table INNER JOIN Othertable ON Table.Column = Othertable.Column
WHERE (((Table.Column)=[Forms]![Formname]![cboname]))
ORDER BY Othertable.Column;
 
J

John Spencer

1)
Try changing the SQL of the Row source to something like the following
SELECT Table.Column
FROM Table INNER JOIN Othertable ON Table.Column = Othertable.Column
WHERE Table.Column=[Forms]![Formname]![cboname]
ORDER BY Othertable.Column;

2)
In the combobox after update event, you need vba code that will requery the
listbox
Me.lstBoxName.Requery 'Replace "lstBoxName" with the name of your
listbox
(Click on combobox; select properties, enter [Event Procedure] in the
After Update event; click on the three dots; enter the above code in the
procedure)

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top