473,387 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Execute non-query related Listbox on Report

ML
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

Nov 23 '06 #1
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

Nov 23 '06 #2
ML
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


Nov 23 '06 #3
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?

Nov 24 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
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...
6
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...
8
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 :...
6
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...
2
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...
2
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...
5
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...
2
Saghar
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...
1
by: Michael Tissington | last post by:
How can I enable execute permissions for a folder on my website using the web.config file ?
1
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...
0
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$) { } ...
0
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.