I have used Allen Brown's technique for filling a listbox on a form with the
names of files in a certain disc folder.
It works well.
I am now giving the user the option to print the form contents in a report
which has the same fields as the form.
All fields derived from report query are OK
A listbox with design mode rowsource setting, works fine BUT...
I wish to use the following (the same call as in the form), to fill a
listbox on the report ...
Private Sub Report_Open()
Dim sTaskPath As String
sTaskPath = "c:\randd\lrs\documents\P_001\SP_001_01\TA_001 "
Call ListFiles(sTaskPath, "*.*", , Me.lstTaskDocuments)
End Sub
It does not work in any report and report section event (including above).
I get a message telling me effectively that setting the rowsource of the
lisbox is inappropriate at this stage of the report.
(Error 2191)
Is there an event I've missed, is this impossible???
Is there no way to dynamically, from code, set the contents of this,
non-bound, listbox, on the fly?
TIA
Michael 3 2645
Instead of using the AddItem method, you could add the items to a great long
string, separated by semicolons, and assign that to the RowSource.
Replace:
For Each varItem In colDirList
lst.AddItem varItem
Next
with:
For Each varItem In colDirList
strOut = strOut & """" & varItem & """;"
Next
lst.RowSource = Left(strOut, Len(strOut) - 1)
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"ML" <md*****@bigpond.net.auwrote in message
news:v%*******************@news-server.bigpond.net.au...
>I have used Allen Brown's technique for filling a listbox on a form with the names of files in a certain disc folder.
It works well.
I am now giving the user the option to print the form contents in a report
which has the same fields as the form.
All fields derived from report query are OK
A listbox with design mode rowsource setting, works fine BUT...
I wish to use the following (the same call as in the form), to fill a
listbox on the report ...
Private Sub Report_Open()
Dim sTaskPath As String
sTaskPath = "c:\randd\lrs\documents\P_001\SP_001_01\TA_001 "
Call ListFiles(sTaskPath, "*.*", , Me.lstTaskDocuments)
End Sub
It does not work in any report and report section event (including above).
I get a message telling me effectively that setting the rowsource of the
lisbox is inappropriate at this stage of the report.
(Error 2191)
Is there an event I've missed, is this impossible???
Is there no way to dynamically, from code, set the contents of this,
non-bound, listbox, on the fly?
TIA
Michael
Thanks, Allen
It would appear that re-setting the rowsource is OK at Open, but trying to
independently populate - as opposed to sourcing, on the fly, is something
the
report engine - designed to interpret its report query - and any "pre
sourced" listboxes, won't do.
The 2191 runtime error message, made me think that the problem was with the
rowsource assignment at Open, which was odd because I have set rowsource at
Open before.
The real problem was trying to carry out some independent assignment
execution on a report control - the explicit item by item filling of the
listbox control.
Michael
"Allen Browne" <Al*********@SeeSig.invalidwrote in message
news:45**********************@per-qv1-newsreader-01.iinet.net.au...
Instead of using the AddItem method, you could add the items to a great
long string, separated by semicolons, and assign that to the RowSource.
Replace:
For Each varItem In colDirList
lst.AddItem varItem
Next
with:
For Each varItem In colDirList
strOut = strOut & """" & varItem & """;"
Next
lst.RowSource = Left(strOut, Len(strOut) - 1)
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"ML" <md*****@bigpond.net.auwrote in message
news:v%*******************@news-server.bigpond.net.au...
>>I have used Allen Brown's technique for filling a listbox on a form with the names of files in a certain disc folder. It works well.
I am now giving the user the option to print the form contents in a report which has the same fields as the form.
All fields derived from report query are OK A listbox with design mode rowsource setting, works fine BUT...
I wish to use the following (the same call as in the form), to fill a listbox on the report ...
Private Sub Report_Open() Dim sTaskPath As String sTaskPath = "c:\randd\lrs\documents\P_001\SP_001_01\TA_001 " Call ListFiles(sTaskPath, "*.*", , Me.lstTaskDocuments) End Sub
It does not work in any report and report section event (including above).
I get a message telling me effectively that setting the rowsource of the lisbox is inappropriate at this stage of the report. (Error 2191)
Is there an event I've missed, is this impossible???
Is there no way to dynamically, from code, set the contents of this, non-bound, listbox, on the fly?
TIA Michael
It would not be too hard to populate a temporary table with the file names
instead of adding to a list box.
At the top of the code, clear the table, and open it:
Dim dbAs DAO.Database
Dim rs As DAO.Recordset
Set db = dbEngine(0)(0)
db.Execute "DELETE FROM tblFile;"
Set rs = db.OpenTable("tblFile")
Instead of adding the the collection, add to the recordset:
rs.AddNew
rs!TheFile = varItem
rs.Update
At the end of the code:
rs.Close
Set rs= Nothing
Set db = Nothing
You can now use tblFile as the RecordSource for your report.
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"ML" <md*****@bigpond.net.auwrote in message
news:1T*****************@news-server.bigpond.net.au...
Thanks, Allen
It would appear that re-setting the rowsource is OK at Open, but trying to
independently populate - as opposed to sourcing, on the fly, is something
the
report engine - designed to interpret its report query - and any "pre
sourced" listboxes, won't do.
The 2191 runtime error message, made me think that the problem was with
the rowsource assignment at Open, which was odd because I have set
rowsource at Open before.
The real problem was trying to carry out some independent assignment
execution on a report control - the explicit item by item filling of the
listbox control.
Michael
"Allen Browne" <Al*********@SeeSig.invalidwrote in message
news:45**********************@per-qv1-newsreader-01.iinet.net.au...
>Instead of using the AddItem method, you could add the items to a great long string, separated by semicolons, and assign that to the RowSource.
Replace: For Each varItem In colDirList lst.AddItem varItem Next with: For Each varItem In colDirList strOut = strOut & """" & varItem & """;" Next lst.RowSource = Left(strOut, Len(strOut) - 1)
"ML" <md*****@bigpond.net.auwrote in message news:v%*******************@news-server.bigpond.net.au...
>>>I have used Allen Brown's technique for filling a listbox on a form with the names of files in a certain disc folder. It works well.
I am now giving the user the option to print the form contents in a report which has the same fields as the form.
All fields derived from report query are OK A listbox with design mode rowsource setting, works fine BUT...
I wish to use the following (the same call as in the form), to fill a listbox on the report ...
Private Sub Report_Open() Dim sTaskPath As String sTaskPath = "c:\randd\lrs\documents\P_001\SP_001_01\TA_001 " Call ListFiles(sTaskPath, "*.*", , Me.lstTaskDocuments) End Sub
It does not work in any report and report section event (including above).
I get a message telling me effectively that setting the rowsource of the lisbox is inappropriate at this stage of the report. (Error 2191)
Is there an event I've missed, is this impossible???
Is there no way to dynamically, from code, set the contents of this, non-bound, listbox, on the fly?
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Thomas Scheiderich |
last post by:
Why would you use the Recordset object over the Execute method of
getting data from your Sql database.
For example, I have the following:
Execute Method...
|
by: PiGei |
last post by:
hi all,
I'm trying to use server.execute statement to include in an asp page
another asp page with a parameter.
That's because I've a parametric query in the second asp page and I have
to pass...
|
by: Jiggaz |
last post by:
Hi,
In my ASPX Page, i have a form for signup. And whene user
click on the button, the event Button1_Click must use a
stored procedure.
But instead of use stored proc, i get this exception :...
|
by: TJS |
last post by:
in vbscript there was a command called "execute" which would process a
dynamic string, vb.net dropped that feature ...
does anybody have a working solution for sale or free that will execute a...
|
by: joe1977 |
last post by:
Win2k3, PHP 5, Apache 2, Acrobat 7
when I go to my server, pull out cmd.exe and type as follows:
"c:\Program Files\Adobe\Acrobat 7.0\\Reader\AcroRd32.exe" /t
"c:\Program Files\Adobe\Acrobat...
|
by: Deere |
last post by:
Keep in mind I'm an old guy who is learning .net.
In asp classic I had a trash can icon in my shopping cart that would
delete a record.
In trying to accomplish the same in gridview I've used a...
|
by: loudwinston |
last post by:
Hello,
I'm encountering a strange error with PDO. The server is FreeBSD 4.4,
PHP 5.1.2, mySQL 4.0.20 with 4.1.18 client libs.
I have the following code (usernames and passwords changed to...
|
by: Saghar |
last post by:
Hi,
Could somebody help me about this topic? I want to know how we can call and execute a non-java source file in a java application. For example, a simple Java application is run, there is an...
|
by: Michael Tissington |
last post by:
How can I enable execute permissions for a folder on my website using the
web.config file ?
|
by: mikegolden |
last post by:
An application I'm working on makes extensive use of output parameters and return values, thus forcing me to use the ADODB Command object to execute the stored procs. For recordset returning stored...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |