Modifying Entered data

S

Sok Hong

Hello, I've currently set some check boxes to enter in
text such as "Tech" upon selection into a Control
Source "Word". With the code,

Sub Tech_AfterUpdate()

If Me.Tech = True Then
Me.Word = Me.Word & "Tech, "
End If

EndSub

This code was added for each of the check boxes. However,
I want to add the functionality that text will be taken if
the selection is deselected. Also, I want to delete the
last two characters after all the text has been entered
and replace it with a ".". So it'll get rid of ", " and
replace with a "." at the end. Any suggestions on how to
do any of these?
 
T

TC

Sok Hong said:
Hello, I've currently set some check boxes to enter in
text such as "Tech" upon selection into a Control
Source "Word". With the code,

Sub Tech_AfterUpdate()

If Me.Tech = True Then
Me.Word = Me.Word & "Tech, "
End If

EndSub

This code was added for each of the check boxes. However,
I want to add the functionality that text will be taken if
the selection is deselected.

In afterupdate of the checkbox, if the new value is false:
- use the Instr() function to find the occurrence of the text in question,
then
- use the Left$() function to get the parts before that text,
- and the Mid$() function to get the stuff *after* that text, then
- put the two parts back together (omitting the unwanted text).

Also, I want to delete the
last two characters after all the text has been entered
and replace it with a ".". So it'll get rid of ", " and
replace with a "." at the end.

You don't know whether the user finished clicking the boxes, until he tries
to save the changes. So I would put some code in the beforeupdate event of
the form (not the checkboxes), for that.

HTH,
TC
 

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

Top