I have been racking my brain for a week now and if you don't mind I would like to throw it to the group to see what the folks think.
I have a database that holds100 records, there are multiple fields in each record but there is one in particular that is defined as a string and contains numbers that are deliminated by commas,(ie:"1,2 ,3,6,8,9"). Now the version of Access allows me to do a split with no problem and I have successfully been able to read each number from the array created by the split. Here is where is have been running into a wall...I have to display on a report nine checkboxes but I only want the ones checked that are in the string of each of the 100 records.
So for instance if the first record has a text string of "1,2,3,4" on the report of that record I only want the boxes checked for 1,2,3, and 4.
If the second record is "1,2,5,9" then I only want those corresponding boxes checked.
The road that I have been down now is a function that I put in the detailed area of the report. Here is that code for the function: -
Public Function WhichLocationsAreChecked(Location_str As String) As Integer
-
Dim ThePosition As Integer
-
Dim TheChar As String
-
Dim TheCnt, LoopCnt As Integer
-
Dim Location_arr() As String
-
-
TheChar = ","
-
-
Location_arr = Split(Location_str, TheChar)
-
TheCnt = UBound(Location_arr) + 1
-
-
For LoopCnt = 1 To TheCnt Step 1
-
Select Case Location_arr(LoopCnt - 1)
-
Case 1
-
Reports!businessunitproductmeeting!Gainesville_chkbx.Value = True
-
Case 2
-
Reports!businessunitproductmeeting!Greenwood_chkbx.Value = True
-
Case 3
-
Reports!businessunitproductmeeting!Huntington_chkbx.Value = True
-
Case 4
-
Reports!businessunitproductmeeting!Ladysmith_chkbx.Value = True
-
Case 5
-
Reports!businessunitproductmeeting!Logan_chkbx.Value = True
-
Case 6
-
Reports!businessunitproductmeeting!Med_CP_chkbx.Value = True
-
Case 7
-
Reports!businessunitproductmeeting!Med_Glass_chkbx.Value = True
-
Case 8
-
Reports!businessunitproductmeeting!Med_MW_chkbx.Value = True
-
Case 9
-
Reports!businessunitproductmeeting!Med_Vinyl_chkbx.Value = True
-
Case 10
-
Reports!businessunitproductmeeting!Mosinee_chkbx.Value = True
-
Case 11
-
Reports!businessunitproductmeeting!Parkfalls_chkbx.Value = True
-
End Select
-
Next LoopCnt
-
-
WhichLocationsAreChecked = TheCnt
-
-
-
End Function
-
So is there any ideas, any hope or should I quit and become a rodeo clown?
Thanks,
Mike
3 1526 PEB 1,418
Recognized Expert Top Contributor
Hi Mike,
I suppose this function that you've created is invoked from the detail section...
If i've been in your place i would prefer to do the split on query level.. Creating as columns all possible values of checkboxes in your report..
So in your report you shouldn't write any code...
And in fact you need to create only one function in a module that returns the respective number of array obtained by split..
Like this one:
Function Verify_word_in_ array(My_field, wanted_value) as boolean
if i try to express myself in russian...
End function
So in your query your first column for check should be like:
Check1: Verify_word_in_ array("1,2,3,4" ,"1")
Check2: Verify_word_in_ array("1,2,3,4" ,"2")
......
Check9: Verify_word_in_ array("1,2,3,4" ,"9")
Sometimes it just takes posting a question and then a good walk. As I was looking over some documentation for a good rodeo clown college I said just take it back to basics...a function should only return 1 thing so I changed the code and ran the function from each checkbox control on the "on open" event and it works like a charm. Here is the code: -
Public Function WhichLocationsAreChecked(Location_str As String, Target As Integer) As Boolean
-
Dim TheChar As String
-
Dim TheCnt, LoopCnt As Integer
-
Dim Location_arr() As String
-
Dim Boolean_flg As Boolean
-
-
TheChar = ","
-
Boolean_flg = False
-
Location_arr = Split(Location_str, TheChar)
-
TheCnt = UBound(Location_arr) + 1
-
-
For LoopCnt = 1 To TheCnt Step 1
-
If Location_arr(LoopCnt - 1) = Target Then
-
Boolean_flg = True
-
End If
-
Next LoopCnt
-
-
WhichLocationsAreChecked = Boolean_flg
-
End Function
-
I would like to thank all who wrote back or hell even took a look at this.
be good,
Mike
Hi Mike,
I suppose this function that you've created is invoked from the detail section...
If i've been in your place i would prefer to do the split on query level.. Creating as columns all possible values of checkboxes in your report..
So in your report you shouldn't write any code...
And in fact you need to create only one function in a module that returns the respective number of array obtained by split..
Like this one:
Function Verify_word_in_ array(My_field, wanted_value) as boolean
if i try to express myself in russian...
End function
So in your query your first column for check should be like:
Check1: Verify_word_in_ array("1,2,3,4" ,"1")
Check2: Verify_word_in_ array("1,2,3,4" ,"2")
......
Check9: Verify_word_in_ array("1,2,3,4" ,"9")
PEB 1,418
Recognized Expert Top Contributor Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Robert |
last post by:
Hello Accessors
I have some reports created in Access that are very good for what they do.
However, it seems to me that when you are displaying information you don't
need to print out that a printer-friendly report is not the best way to go.
So, I tried converting one of my Access reports to an Access form. I
selected the continuous view to allow displaying multple records but when I
went to define my sorting and grouping there was none...
|
by: Justin Koivisto |
last post by:
I am trying to create a report that displays a name of an advertising
source and count of the number of times it was hit between certain date
ranges. The data is split between two different databases: this access
db, and a remote MySQL server. The MySQL tables are linked in the access db.
What I have done so far is created an On Open event for a report that
does the following:
* prompt user for the date range
* get which sources were...
|
by: dog |
last post by:
I've seen plenty of articles on this topic but none of them have been
able to solve my problem.
I am working with an Access 97 database on an NT4.0 machine, which has
many Access reports.
I want my users to be able to select a report, click on a command
button on a form, which will then automatically create the report as a
pdf file and save it to the user's machine.
I am using Adobe Acrobat (5.0 I think) and have Adobe Distiller as a
|
by: Jorge Cecílio |
last post by:
Hi!
I would like to export some MS-Access reports output to pdf.
However, the only possibility offered by Access (afaik) for me to export
formatted output is snp (snapshot) (I use MS-Office XP Prof. 2002 version).
With formatted output I mean the *exactly* output I produce from executing
my report (information is gathered from an ODBC database).
|
by: Grasshopper |
last post by:
Hi,
I am automating Access reports to PDF using PDF Writer 6.0. I've
created a DTS package to run the reports and schedule a job to run this
DTS package. If I PC Anywhere into the server on where the job is
running, the job runs sucessfully, PDF files got generated, everything
is good. If I scheduled the job to run at the time that I am not
logged into the server, Access is not able to print to the printer.
The error is pretty...
| |
by: pepsi330ml |
last post by:
I have a Report A, which compute daily sales.
Example:
Date: 18 Jan 06
Pen - 4 pieces
Ruler - 5 pieces
Pencil - 7 pieces
Date: 19 Jan 06
Pen - 3 pieces
Ruler - 5 pieces
|
by: gm |
last post by:
Hi;
I have written a database that tracks all the installation we have ever
done. I have a small heating company.
I have recently started keeping a directory of digital photographs of the
completed job. I can create a hyperlink button that will link to a
photgraph, but I cannot link to a specific photo of that specific job. Each
job has its' own unique identifier, I call it the GOTC number. It is a
separate field in the table of installed...
|
by: ricktech101 |
last post by:
Hi,
I have a table with a field that shows the number of pieces that a
parcel contains. It looks like this:
ParcelID, Pieces, Description
Data example:
1001, 5, Jackets
1002, 10, shoes
etc
|
by: pic078 via AccessMonster.com |
last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files)
that remains stuck in task manager after exiting the application - you can't
reopen database after exiting as a result - I have read every post out there
and spent hours trying to figure out the problem with no success whatsoever -
I have constrained the problem to one form however, and I think it's hiding
somewhere in my code associated with this form, which is...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |