Dear Sunny:
This wouldn't be so hard to do.
Once you type in the query, you need to pick an event that assigns
that query as the RowSource of your List Box. This could be the Exit
event of the text box, or the click event of some button.
The List box will then display your results.
There would be several disadvantages to having it do that:
- You would have to type the SQL without the slightest error.
However, you could save a list of SQL statements that are "pretested"
and choose from that list, if that would help.
- The number of columns in the List Box and the widths of those
columns would not be appropriate. You could make an API call to find
the widest value in each column and set them up that way, as well as
assigning the number of columns. You could also set the font size so
it fits.
I suggest you may want to use a datasheet instead of a list box. This
would allow the users to adjust the column widths themselves.
This kind of operation wouldn't be suitable for the average user. If
the person for whom you want this is technical enough to author their
own SQL, they ought to be able to just use the SQL view of a query and
open the datasheet from there. So, is there anything to be gained by
this?
Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts