Changing value of field depending on a checkbox

V

Veli Izzet

Hi all,

I want to change the value of one field when depending on if a checkbox
true or false with VB.

If the checkbox is TRUE,
The value of Field1 shall be Field1Value&"-ABCD",

if it is FALSE,
The Value of Field1 shall be Field2Value&"-XYZ".

Can anybody help with the syntax please.
 
S

Steve Schapel

Veli,

This would be easy to do - except for the possibility of the checkbox
being changed more than once, which adds an extra complexity, in that
you need to reverse any previous setting.

So really, I would strongly advise against doing this. In fact, I'm
pretty sure you are asking the impossible. When do you want this field
value adjustment to take place? When the checkbox is ticked or
unticked? When you access the next record on the form? If I take your
example literally, you could put code like this on the After Update
event of the checkbox, or the Current event of the Form, or some such...

If Me.YourCheckbox Then
Me.Field1 = Me.Field1 & "-ABCD"
Else
Me.Field1 = Me.Field2 & "-XYZ"
End If

But let's say Field1 has data like this...
"fred"
and Field2 has data like this...
"betty"
and the checkbox is ticked, so whenever the critical event takes place,
Field1 would change to...
"fred-ABCD"
and the next time the critical event takes place, Field1 changes to...
"fred-ABCD-ABCD"
or the checkbox is unticked, and Field1 changes to...
"betty-XYZ"
and then the checkbox is ticked again, so then we have...
"betty-XYZ-ABCD"

So, in other words, I think it would be good if you could explain the
data you are working with, and what you are trying to achieve here, and
someone may be able to suggest another approach.
 
V

Veli Izzet

Thanks Steve,

It seems this is the functionality I want; to keep a small history of
few events in a field.

I will see if this turns out to be a stupid idea, however.:)
 

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