PC Review


Reply
Thread Tools Rate Thread

Changing value of field depending on a checkbox

 
 
Veli Izzet
Guest
Posts: n/a
 
      11th Feb 2006
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.
 
Reply With Quote
 
 
 
 
Steve Schapel
Guest
Posts: n/a
 
      11th Feb 2006
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.

--
Steve Schapel, Microsoft Access MVP


Veli Izzet wrote:
> 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.

 
Reply With Quote
 
Veli Izzet
Guest
Posts: n/a
 
      11th Feb 2006
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.:-)

Steve Schapel wrote:
> 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.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
hyperlink to changing field depending on input Stephen Microsoft Excel Programming 6 22nd Apr 2009 07:28 PM
Field value depending on the checkbox =?Utf-8?B?Um9iYmllIERvbw==?= Microsoft Access Reports 1 4th Jul 2007 05:34 PM
Checkbox changing whether another field is visible or not =?Utf-8?B?QWNjZXNzTm92aWNl?= Microsoft Frontpage 2 30th Sep 2006 07:58 PM
show field depending on checkbox =?Utf-8?B?VkI=?= Microsoft Access Forms 12 7th Nov 2005 01:45 AM
MS Access - Changing content of a calculated field based on value of checkbox-Help! aaldridge Windows XP 3 20th Jun 2005 06:51 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:54 AM.