Checkbox and entering text into table

  • Thread starter Thread starter Sok Hong
  • Start date Start date
S

Sok Hong

Hello, I am working a form full of checkboxes,(more than
one can be selected at a time). I am currently trying to
set the check boxes so that when the user selects a
choice, a specific text message will be entered into the
table. It was achieved with the code shown below:

Private Sub Check76_AfterUpdate()

If [Check76].Value = True Then
[Word].Value = "Billing"

End If


End Sub

Private Sub Check81_AfterUpdate()

If [Check81].Value = True Then
[Word].Value = "SUBP"
End If

End Sub


However, I want the text to be added on not replace one
another. For example, if I selected both [Check76] and
[Check81] I want the cell in the table to display
both "billing" and "subp", any clues on how to do that?
Also, is there a way to erase that text if the checkbox is
deselected? Thank you.
 
Hi,
You can do this:
Me.Word = Me.Word & "SUBP"

It means, take the value that is there and append "SUBP"

Do that for all the events.
 
Is there a way to erase the entry in case the check box
gets deselected by the user?

Secondly, do you know of a code that will erase the last
two characters in a field, and replace that with with a
different character?

-----Original Message-----
Hi,
You can do this:
Me.Word = Me.Word & "SUBP"

It means, take the value that is there and append "SUBP"

Do that for all the events.

--
HTH
Dan Artuso, Access MVP


"Sok Hong" <[email protected]> wrote in
message news:[email protected]...
Hello, I am working a form full of checkboxes,(more than
one can be selected at a time). I am currently trying to
set the check boxes so that when the user selects a
choice, a specific text message will be entered into the
table. It was achieved with the code shown below:

Private Sub Check76_AfterUpdate()

If [Check76].Value = True Then
[Word].Value = "Billing"

End If


End Sub

Private Sub Check81_AfterUpdate()

If [Check81].Value = True Then
[Word].Value = "SUBP"
End If

End Sub


However, I want the text to be added on not replace one
another. For example, if I selected both [Check76] and
[Check81] I want the cell in the table to display
both "billing" and "subp", any clues on how to do that?
Also, is there a way to erase that text if the checkbox is
deselected? Thank you.


.
 
What version of Access? 2000 and later then you can use the replace function.

Private Sub Check76_AfterUpdate()

If Me.Check76 = True Then
Me.Word = "SUBP " & Me.Word
Else
Me.Word = Replace(Me.Word & " ","SUBP ","")
End If

End Sub

It is generally a bad idea to store more than one piece of information in a
field. You might want to look at adding another table to store these values and
a reference to the row in the main table.

Sok said:
Is there a way to erase the entry in case the check box
gets deselected by the user?

Secondly, do you know of a code that will erase the last
two characters in a field, and replace that with with a
different character?
-----Original Message-----
Hi,
You can do this:
Me.Word = Me.Word & "SUBP"

It means, take the value that is there and append "SUBP"

Do that for all the events.

--
HTH
Dan Artuso, Access MVP


"Sok Hong" <[email protected]> wrote in
message news:[email protected]...
Hello, I am working a form full of checkboxes,(more than
one can be selected at a time). I am currently trying to
set the check boxes so that when the user selects a
choice, a specific text message will be entered into the
table. It was achieved with the code shown below:

Private Sub Check76_AfterUpdate()

If [Check76].Value = True Then
[Word].Value = "Billing"

End If


End Sub

Private Sub Check81_AfterUpdate()

If [Check81].Value = True Then
[Word].Value = "SUBP"
End If

End Sub


However, I want the text to be added on not replace one
another. For example, if I selected both [Check76] and
[Check81] I want the cell in the table to display
both "billing" and "subp", any clues on how to do that?
Also, is there a way to erase that text if the checkbox is
deselected? Thank you.


.
 
Back
Top