Alternatively is there a way (in vb) to store the result of the SQL statement into the Textbox..
eg:
-
Me.MyTextBox = DoCmd.RunSQL "Select............"
-
-
-
or
-
-
-
Dim sqlvalue as string
-
sqlvaue = Docmd.RunSQL "Select............"
-
me.MyTextBox = sqlvalue
-
Rob
I'm afraid you are way off the mark with that one I understand your thought process, but you are talking about the return of recordsets and how you deal with the physical data returned as a two dimensional matrix.
Docmd.RunSQL whilst incredibly useful is not the panacea to all it runs 'Action' or data definition queries
INSERT INTO, DELETE, SELECT...INTO, UPDATE, CREATE TABLE, ALTER TABLE, DROP TABLE, CREATE INDEX, or DROP INDEX statements
Note.... NOT.... SELECT statements (which return datasets and from which your listboxs rely for their data)
So in short...you simply cannot throw a multi column two dimensional recordset into a string variable
When I mentioned you were handling the data twice that is correct. Your answer lies optimally in opening up a RECORDSET in Code and looping through the recordset, grabbing datavalues as you loop through the recordset (in much the same way as my earlier example to you) concatenating the results in whichever way befits your requirement ie: is it one column or two or maybe more columns that you wish to grab .....
if so how do you intend to equally space datavalues if the data is to be dumped into the textbox. IF there is more than one column and so on.
It is entirely possible for you to open a recordset loop through it and assign the result to the textbox without ever having any listbox on your report you merely have to understand the concept of recordsets generally, how they get opened in memory, how you loop through and grab their values importantly and especially within the context of what you wish to do currently how to massage and manipulate that data to FILL the textbox with it.
Unfortunately every method or property has its limitations scoped to the intention of, as in this case.......the 'control' as we appreciate that 'actually' what you are trying to do is make a textbox into a listbox.
You will probably think this is way too much work to do to achieve something which, and I would agree with you seems like a simple request.
The elegance of programming mimicry very often lies in the skilful understanding of workarounds because, as you quite rightly point out, a listbox doesnt grow and behave like a textbox by default.
Have a look at the openrecordset method in Access help
I hope this helps you a bit further
Regards
Jim