views:

142

answers:

1

I have created a unbound listbox. I have the box showing a list of queries I want the use to be able to select. My problem is I don't understand how to get the submit button to select the currently selected query and run it.

So how do I link the submit button to the listbox and have each item in the box submit its own query.

A: 

Does the listbox contain a query name or the actual SQL? Either way, something like

CurrentDB.Execute(Me![ListBox])

in the submit button event handler should get you going in the right direction.

BenV
The list box contains a query.SELECT [Name] FROM MSysObjects WHERE [Type]=5 And Left([Name],1)<>"~" ORDER BY [Name];
Jeremy
CurrentDB.Execute does not work on anything but DDL or DML statements, i.e., no SELECT.
David-W-Fenton
You're exactly right. I assumed he wasn't doing a select since he wanted to execute it in the background.
BenV
I would have assumed the same thing. I don't think it's a very good UI, to be honest.
David-W-Fenton