running a query in VB

P

Peter Morris

I have a form with a subform. The subform displays the results of a saved
query.
How do I set a parameter for the query and redraw the subform?

That's probably not clear what I mean.

My query is : SELECT * FROM my_table WHERE col1 = p_value;

When I run my form, I want to select an item in the listbox and use
that selection for p_value. Then redraw the subform with the results.

What is the syntax for doing this in VB?
 
C

Crystal

Hi Peter,

instead of using criteria in your query in the subform
recordsource, try this for the subform

RecordSource --> my_table

make sure that Col1 is on the subform (it can be hidden) and
that the NAME of the control is also Col1

then, from the mainform, click on the subform control one time

LinkMasterFields --> listbox_controlname
LinkChildFields --> Col1

where
listbox_controlname is the NAME property of the listbox

Please post back if you need clarification

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com
 

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

Top