Multiple Check boxes to text in report

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form with 13 check boxes, one for each division that can provide
input to a given topic. I want to have division names displayed on the
report in a single text box separated by commas. I can get one name to
appear but cannot figure out how to get more than one. I used: =IIf([AA]=
True, "AA", "") for one. Any help would be appreciated. Thanks.
 
Jay said:
I have a form with 13 check boxes, one for each division that can provide
input to a given topic. I want to have division names displayed on the
report in a single text box separated by commas. I can get one name to
appear but cannot figure out how to get more than one. I used: =IIf([AA]=
True, "AA", "") for one. Any help would be appreciated. Thanks.

You'll need to go through all 13 boxes and build your string, and then
trim the final comma.

Create yourself a function such as this:

Private Function GetDivisions() as String
Dim strTempDiv as String

strTempDiv = ""

' Build your string
If [AA] = True Then strTempDiv = strTempDiv & "AA, "
If [BB] = True Then strTempDiv = strTempDiv & "BB, "
If [CC] = True Then strTempDiv = strTempDiv & "CC, "
' .. Other checks as necessary ..

' Delete the trailing comma and space
strTempDiv = Left(Len(strTempDiv), -2)
GetDivisions = strTempDiv

End
 
If your table structure was normalized, this might be a little easier.
Division names are data values, not field names.

--
Duane Hookom
MS Access MVP

Duncan Bachen said:
Jay said:
I have a form with 13 check boxes, one for each division that can provide
input to a given topic. I want to have division names displayed on the
report in a single text box separated by commas. I can get one name to
appear but cannot figure out how to get more than one. I used:
=IIf([AA]= True, "AA", "") for one. Any help would be appreciated.
Thanks.

You'll need to go through all 13 boxes and build your string, and then
trim the final comma.

Create yourself a function such as this:

Private Function GetDivisions() as String
Dim strTempDiv as String

strTempDiv = ""

' Build your string
If [AA] = True Then strTempDiv = strTempDiv & "AA, "
If [BB] = True Then strTempDiv = strTempDiv & "BB, "
If [CC] = True Then strTempDiv = strTempDiv & "CC, "
' .. Other checks as necessary ..

' Delete the trailing comma and space
strTempDiv = Left(Len(strTempDiv), -2)
GetDivisions = strTempDiv

End
 
Thanks Duncan. Duane, what would be a better way to do this? Thanks.

Duane Hookom said:
If your table structure was normalized, this might be a little easier.
Division names are data values, not field names.

--
Duane Hookom
MS Access MVP

Duncan Bachen said:
Jay said:
I have a form with 13 check boxes, one for each division that can provide
input to a given topic. I want to have division names displayed on the
report in a single text box separated by commas. I can get one name to
appear but cannot figure out how to get more than one. I used:
=IIf([AA]= True, "AA", "") for one. Any help would be appreciated.
Thanks.

You'll need to go through all 13 boxes and build your string, and then
trim the final comma.

Create yourself a function such as this:

Private Function GetDivisions() as String
Dim strTempDiv as String

strTempDiv = ""

' Build your string
If [AA] = True Then strTempDiv = strTempDiv & "AA, "
If [BB] = True Then strTempDiv = strTempDiv & "BB, "
If [CC] = True Then strTempDiv = strTempDiv & "CC, "
' .. Other checks as necessary ..

' Delete the trailing comma and space
strTempDiv = Left(Len(strTempDiv), -2)
GetDivisions = strTempDiv

End
 
I would create a related table where a record would be added for each
division for the main record. This would allow you to add more districts if
necessary without changing table structures, forms, etc. You can use code to
concatenate the district names.
--
Duane Hookom
MS Access MVP

Jay said:
Thanks Duncan. Duane, what would be a better way to do this? Thanks.

Duane Hookom said:
If your table structure was normalized, this might be a little easier.
Division names are data values, not field names.

--
Duane Hookom
MS Access MVP

Duncan Bachen said:
Jay wrote:
I have a form with 13 check boxes, one for each division that can
provide
input to a given topic. I want to have division names displayed on
the
report in a single text box separated by commas. I can get one name
to
appear but cannot figure out how to get more than one. I used:
=IIf([AA]= True, "AA", "") for one. Any help would be appreciated.
Thanks.

You'll need to go through all 13 boxes and build your string, and then
trim the final comma.

Create yourself a function such as this:

Private Function GetDivisions() as String
Dim strTempDiv as String

strTempDiv = ""

' Build your string
If [AA] = True Then strTempDiv = strTempDiv & "AA, "
If [BB] = True Then strTempDiv = strTempDiv & "BB, "
If [CC] = True Then strTempDiv = strTempDiv & "CC, "
' .. Other checks as necessary ..

' Delete the trailing comma and space
strTempDiv = Left(Len(strTempDiv), -2)
GetDivisions = strTempDiv

End
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top