I have few list boxes. and I have few buttons which should do the same operation for any of the selected items from any list box.
For example I have a view button which open a report for any selection from a list.
behind the view button I have this code -
-
If (Len([List1]) > 0) Then
-
DoCmd.OpenReport stDocName1, acPreview
-
ElseIf (Len([List2]) > 0) Then
-
DoCmd.OpenReport stDocName2, acPreview
-
ElseIf (Len([List3]) > 0) Then
-
DoCmd.OpenReport stDocName3, acPreview
-
ElseIf (Len([List4]) > 0) Then
-
DoCmd.OpenReport stDocName4, acPreview
-
Else
-
MsgBox "Please select an item from any of the lists provided then press the button", vbCritical, "Warning"
-
End If
-
the problem is that it only let me view the report for the first selection,
for example I select an item from list1, it works fine and I see the reports, but when i go and select an item from list2 two, it still shows me the same report from the first selection.
Any ideas why?
Regards,
5 1401
I have few list boxes. and I have few buttons which should do the same operation for any of the selected items from any list box.
For example I have a view button which open a report for any selection from a list.
behind the view button I have this code -
-
If (Len([List1]) > 0) Then
-
DoCmd.OpenReport stDocName1, acPreview
-
ElseIf (Len([List2]) > 0) Then
-
DoCmd.OpenReport stDocName2, acPreview
-
ElseIf (Len([List3]) > 0) Then
-
DoCmd.OpenReport stDocName3, acPreview
-
ElseIf (Len([List4]) > 0) Then
-
DoCmd.OpenReport stDocName4, acPreview
-
Else
-
MsgBox "Please select an item from any of the lists provided then press the button", vbCritical, "Warning"
-
End If
-
the problem is that it only let me view the report for the first selection,
for example I select an item from list1, it works fine and I see the reports, but when i go and select an item from list2 two, it still shows me the same report from the first selection.
Any ideas why?
Regards,
Most probably due to your ElseIf's?
Why dont u just do if statements without doing any else in -
Dim bReportDone as Boolean
-
-
bReportDone = False
-
-
If (Len([List1]) > 0) Then
-
DoCmd.OpenReport stDocName1, acPreview
-
bReportDone = True
-
End if
-
-
If (Len([List2]) > 0) Then
-
DoCmd.OpenReport stDocName2, acPreview
-
bReportDone = True
-
End if
-
-
If (Len([List3]) > 0) Then
-
DoCmd.OpenReport stDocName3, acPreview
-
bReportDone = True
-
End if
-
-
If (Len([List4]) > 0) Then
-
DoCmd.OpenReport stDocName4, acPreview
-
bReportDone = True
-
End if
-
-
If bReportDone = False Then
-
MsgBox "Please select an item from any of the lists provided then press the button", vbCritical, "Warning"
-
End If
-
-
NeoPa 32,556
Expert Mod 16PB
Tara,
pks00's answer will enable you to run multiple reports (for all lists that have anything selected).
If you only want to run the report for the list just selected then you will need to deselect any other lists first.
BTW To use the Select Case statement where the options are based on different variables, you can use code like this :- - Select Case TRUE
-
Case Len(List1)>0
-
{code}
-
Case Len(List2)>0
-
{code}
-
End Select
Select Case is generally recommended over any complicated If structure as it's more manageable and (generally considered) more readable.
Have fun.
Tara,
pks00's answer will enable you to run multiple reports (for all lists that have anything selected).
If you only want to run the report for the list just selected then you will need to deselect any other lists first.
BTW To use the Select Case statement where the options are based on different variables, you can use code like this :- - Select Case TRUE
-
Case Len(List1)>0
-
{code}
-
Case Len(List2)>0
-
{code}
-
End Select
Select Case is generally recommended over any complicated If structure as it's more manageable and (generally considered) more readable.
Have fun.
Hi Neopa
Can you please explain more what do I have to do/
tnx
Have I got my understanding wrong
Do u want to run all the selected reports or just one from any selected item in any list?
I thought it was the former
NeoPa 32,556
Expert Mod 16PB
Hi Neopa
Can you please explain more what do I have to do/
tnx
I will try to answer specific questions but I'm not inclined to do the whole job for you.
If you can explain clearly what it is you need to know or understand I will help if I can.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Brett L. Moore |
last post by:
Hi,
I have had trouble determining whether the STL list.size() operation
is O(1) or O(n). I know the list is a doubly-linked list, so if the
size() operation begins at the head, then counts to...
|
by: Sundown |
last post by:
I am trying to create a custom button control for the web that, when clicked,
disables and changes the text of itself and a bunch of other controls (in the
collection). My goal is to end up with a...
|
by: compupix |
last post by:
I hope I'm in the right group for this.
I'm using Google's Picasa program to create formatted webpages of
my images. Picasa acts on html and tpl files as it creates the final
html pages.
I...
|
by: yariv |
last post by:
Hello All,
I am having a very strange problem.
while trying to access http page on the web.
I happen to have some problems at specific machines.
the exception I get is:
*************...
|
by: John |
last post by:
Here is the current error that im getting when building my solution.
The only thing i can think of is that i needed to install visual
studio 6 after visual studio .net was already installed to...
|
by: RJN |
last post by:
Hi
I have 2 operations to perform one is to upload data and the second is
to generate report. Both take huge time(more than 20 mins and I believe
by that time session would have expired) and...
|
by: Mossman |
last post by:
Hello,
I posted this problem in another thread and received no response. I
need some input at what to look at next. So, if anyone out there as
any suggestions, please respond to this message....
|
by: Abuzar755 |
last post by:
Hello, I have problem with Postgre Sql.
I am beginner in Delphi and also in DataBase.
I want to connect to Postgre Sql via Delphi,I use AdoConnection, DataSource, AdoTable and DBGrid.OnCreate...
|
by: ellishnoo |
last post by:
Hi there,
Please be kind, I have seen some posts where you tell people off for asking without investigating, Im sure most have, anyway I have.
Ive only been doin VB 2008 for 7 weeks, and have...
|
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: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |