473,657 Members | 2,484 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access Report displaying pieces from a String

4 New Member
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:

Expand|Select|Wrap|Line Numbers
  1. Public Function WhichLocationsAreChecked(Location_str As String) As Integer
  2.     Dim ThePosition As Integer
  3.     Dim TheChar As String
  4.     Dim TheCnt, LoopCnt As Integer
  5.     Dim Location_arr() As String
  6.  
  7.     TheChar = ","
  8.  
  9.     Location_arr = Split(Location_str, TheChar)
  10.     TheCnt = UBound(Location_arr) + 1
  11.  
  12.     For LoopCnt = 1 To TheCnt Step 1
  13.         Select Case Location_arr(LoopCnt - 1)
  14.             Case 1
  15.                 Reports!businessunitproductmeeting!Gainesville_chkbx.Value = True
  16.             Case 2
  17.                 Reports!businessunitproductmeeting!Greenwood_chkbx.Value = True
  18.             Case 3
  19.                 Reports!businessunitproductmeeting!Huntington_chkbx.Value = True
  20.             Case 4
  21.                 Reports!businessunitproductmeeting!Ladysmith_chkbx.Value = True
  22.             Case 5
  23.                 Reports!businessunitproductmeeting!Logan_chkbx.Value = True
  24.             Case 6
  25.                 Reports!businessunitproductmeeting!Med_CP_chkbx.Value = True
  26.             Case 7
  27.                 Reports!businessunitproductmeeting!Med_Glass_chkbx.Value = True
  28.             Case 8
  29.                 Reports!businessunitproductmeeting!Med_MW_chkbx.Value = True
  30.             Case 9
  31.                 Reports!businessunitproductmeeting!Med_Vinyl_chkbx.Value = True
  32.             Case 10
  33.                 Reports!businessunitproductmeeting!Mosinee_chkbx.Value = True
  34.             Case 11
  35.                 Reports!businessunitproductmeeting!Parkfalls_chkbx.Value = True
  36.         End Select
  37.     Next LoopCnt
  38.  
  39.     WhichLocationsAreChecked = TheCnt
  40.  
  41.  
  42. End Function
  43.  
So is there any ideas, any hope or should I quit and become a rodeo clown?

Thanks,
Mike
Nov 8 '06 #1
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")
Nov 8 '06 #2
WindowsAndDoors
4 New Member
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:
Expand|Select|Wrap|Line Numbers
  1. Public Function WhichLocationsAreChecked(Location_str As String, Target As Integer) As Boolean
  2.     Dim TheChar As String
  3.     Dim TheCnt, LoopCnt As Integer
  4.     Dim Location_arr() As String
  5.     Dim Boolean_flg As Boolean
  6.  
  7.     TheChar = ","
  8.     Boolean_flg = False
  9.     Location_arr = Split(Location_str, TheChar)
  10.     TheCnt = UBound(Location_arr) + 1
  11.  
  12.     For LoopCnt = 1 To TheCnt Step 1
  13.         If Location_arr(LoopCnt - 1) = Target Then
  14.             Boolean_flg = True
  15.         End If
  16.     Next LoopCnt
  17.  
  18.     WhichLocationsAreChecked = Boolean_flg
  19. End Function
  20.  
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")
Nov 8 '06 #3
PEB
1,418 Recognized Expert Top Contributor
Glad for u!
Nov 18 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
2217
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...
1
2721
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...
7
8850
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
3
4897
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).
11
6584
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...
1
1649
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
1
3107
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...
2
1679
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
9
3937
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...
0
8325
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,...
0
8844
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, 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...
0
8742
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 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...
1
8518
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,...
0
8621
tracyyun
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...
1
6177
isladogs
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...
0
4173
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...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1734
bsmnconsultancy
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...

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.