A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Many Checkbox(s) to one text box?



 
 
Thread Tools Display Modes
  #1  
Old December 14th, 2006, 02:01 PM posted to microsoft.public.access.forms
[email protected]
external usenet poster
 
Posts: 23
Default Many Checkbox(s) to one text box?

Hello again,

I have a form to which I have 4-5 checkbox questions. How do I have the
checkboxes, if checked, displays the results in a bound textbox? For
example:


x is the check

x 1.Maintain tires
_ 2.Check oil
x 3.Fill up with gas
_ 4.Paint car

In my textbox, I need this to be displayed:

Maintain tires, fill up with gas

Even better would be to have, for the first checkbox x 1.Maintian tires
at_____ (where a user can enter a number) then the whole line appear
int he text box. Eg. Maintain tires at 55ppi

Any ideas?

Thanks a million!

  #2  
Old December 14th, 2006, 05:02 PM posted to microsoft.public.access.forms
Sprinks
external usenet poster
 
Posts: 531
Default Many Checkbox(s) to one text box?

Slagg,

This problem is much like building an SQL search string for filtering a
query or report. Loop through the controls, building the string as you go.
You could use a naming convention to refer to the text labels, or place the
text in the Tag property of the checkbox itself to get the associated text.

Sub AssignTextBox()
Dim ctl as Control
Dim strWS as String ' Working String

strWS = ""
For Each ctl in Me.Controls
If ctl.ControlType = acCheckBox Then
strWS = strWS & ctl.Tag & ", "
End If
Next ctl
' Strip comma and space from the end of the string

strWS = Left (strWS, Len(strWS)-2)

' Assign to textbox
Me![YourTextbox] = strWS
End Sub

Then call the subroutine in the AfterUpdate event of each checkbox:
Call AssignTextbox

To handle the more complicated version, handle each case separately, using
another string variable to hold the string to add for each particular case:

Dim strCaseString as String
For Each ctl in Me.Controls
Select Case ctl.Name
Case "chkMaintainTires"
If IsNull(Me![txtTirePressure]) Then
strCaseString = ctl.Tag
Else
strCaseString = ctl.Tag & " at " &
Me![txtTirePressure] & " psi"
End If
.... other cases
End Select
strWS = strWS & strCaseString & ", "
Next ctl

Hope that helps.
Sprinks

" wrote:

Hello again,

I have a form to which I have 4-5 checkbox questions. How do I have the
checkboxes, if checked, displays the results in a bound textbox? For
example:


x is the check

x 1.Maintain tires
_ 2.Check oil
x 3.Fill up with gas
_ 4.Paint car

In my textbox, I need this to be displayed:

Maintain tires, fill up with gas

Even better would be to have, for the first checkbox x 1.Maintian tires
at_____ (where a user can enter a number) then the whole line appear
int he text box. Eg. Maintain tires at 55ppi

Any ideas?

Thanks a million!


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:16 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.