473,473 Members | 2,236 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Displaying text based on multiple checkboxes

20 New Member
Hello All,

So I've got a form with multiple check boxes on it, the user makes selections on this form then clicks next, this opens a second form, on this form i would like to display text in an unbound text box based on the boxes the user has selected.

so if the user selects check box 1,5,and 7 i would like the text box to display:

1,5,7

Is this possible?

Thanks.
Aug 18 '14 #1
6 3178
twinnyfo
3,653 Recognized Expert Moderator Specialist
Xenver,

Yes, this is possible, but you would have to have a specific naming convention for your Check boxes, or have the number for the check box entered into the .Tag property of the checkbox.

You would simply build the string for your unbound text box by cycling through your checkboxes to see if they are checked:

Expand|Select|Wrap|Line Numbers
  1. Dim strValues As String
  2.  
  3. strValues = ""
  4.  
  5. If Me.chkBox1 then
  6.     If strValues = "" then
  7.         strValues = Me.chkBox1.Tag
  8.     Else
  9.         strValues = strValues & "," & Me.chkBox1.Tag
  10.     End If
  11. end if
  12.  
  13. If Me.chkBox2 then
  14.     If strValues = "" then
  15.         strValues = Me.chkBox2.Tag
  16.     Else
  17.         strValues = strValues & "," & Me.chkBox2.Tag
  18.     End If
  19. end if
  20.  
  21. . . . .
  22.  
  23. Me.txtBox = strValues
Hope this gets you moving in the right direction.
Aug 18 '14 #2
Xenver
20 New Member
Hello,

Thanks yes this is very helpful. I think i can use this to do what i want to do but... this is a little embarrassing but i don't know where to enter the code... whenever I've used code before it's been in the code builder for an event (on click etc.) Thanks for the quick response too, everyone on this forum is so helpful!
Aug 18 '14 #3
Xenver
20 New Member
Ok,so I'm using the code in an OnLoad event, and translated to use my forms names it looks like this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_Load()
  2.  
  3. Dim strValues As String
  4.  
  5. strValues = ""
  6.  
  7. If [Forms]![frm_Reports Credit]![SS 1] Then
  8.     If strValues = "" Then
  9.         strValues = [Forms]![frm_Reports Credit]![SS 1]
  10.     Else
  11.         strValues = strValues & "," & [Forms]![frm_Reports Credit]![SS 1].Tag
  12.     End If
  13. End If
  14.  
  15. If [Forms]![frm_Reports Credit]![SS 2] Then
  16.     If strValues = "" Then
  17.         strValues = [Forms]![frm_Reports Credit]![SS 2].Tag
  18.     Else
  19.         strValues = strValues & "," & [Forms]![frm_Reports Credit]![SS 2].Tag
  20.     End If
  21. End If
  22.  
  23.  
  24. Me.DisplayCredits = strValues
  25.  
  26. End Sub
  27.  
  28.  
  29.  
but i get an error on line 15, it says :

"run-time error 94 invalid use of null"

Thanks.
Aug 18 '14 #4
twinnyfo
3,653 Recognized Expert Moderator Specialist
Check to make sure that your check box has the Triple State Property set to No. This property allows a Check box to have three values "True", "False" and "Null" (when a value has not been specifically assigned to it.
Aug 18 '14 #5
Xenver
20 New Member
Hey,

I checked, and all the check boxes had their triple state property set to No, but for some reason when the form was first opened, until they were clicked they started with a blue fill, I'm guessing that indicated a null value because i went through and set all of their default values to 0 and the blue fill went away and everything works fine now. Thanks a lot!
Aug 18 '14 #6
twinnyfo
3,653 Recognized Expert Moderator Specialist
Glad we could be of some help. Let us know if you have any other questions.
Aug 18 '14 #7

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

Similar topics

6
by: jeffsnox | last post by:
Hi, I have multiple checkboxes on the same form as follows: <input type='checkbox' name='cbtype' value='1'> <input type='checkbox' name='cbtype' value='2'> <input type='checkbox'...
4
by: ramapv | last post by:
can i highlight a checkbox from a group of checkbox with particular name which is given as a search key. I am having a list of checkboxes and i have to select some of them and form a group.but i'm...
4
by: favor08 | last post by:
I have a continious subform that 9000 + records and I have serveral check marks on the subform. so it ties to that record. Does anyone have any examples were they use multiple checkboxes in a ...
0
by: Ned Balzer | last post by:
Hi, Can anyone point me in the direction of a solution for validating multiple checkboxes in an asp.net 2.0 page? 1) This is not a checkboxlist, it is a number of separate checkboxes 2) I do...
1
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being...
0
by: JosAH | last post by:
A Simple Text-Based Menu System Read this this post; there are numerous posts like that: a newbie struggling with some sort of menu implementation. They want nested menus of course and an option...
0
by: kimmelsd33 | last post by:
I am adding to my software. I have placed about 30 checkboxes on a form. Based on which checkboxes are selected, I want to print the values to a tab delimited text file. For instance, the first...
12
by: BabyLucifer666 | last post by:
Hello All, (using Access2000) I have a form with multiple unbound checkboxes. What I would like to do is have the user check whoever needs to take a specific training course. My database is...
5
by: pavan52 | last post by:
I have 1 form in with multiple checkboxes in it (each with the code): <input type="checkbox" value="$cat_tit" name="check_list" id="cat_title" /> How would I be able to tell which checkboxes...
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
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...
1
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...
0
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...
1
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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...

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.