Default Value

G

Guest

I have a database that I am using to track employee activity. My table/form
includes 14 check boxes, ie: Retirement, Resignation, Transfer In, New Hire,
etc.

I have another field that is a "Net Effect" field. I would like this field
to automatically populate with a 1 or -1 depending on which box is checked.
Is this possible? Is there a better way of doing this?

I am not an advanced user by any means, but I can muddle my way through.

Any help would be appreciated.

Thanks!
 
K

Ken Snell [MVP]

Yes, you could use the form's BeforeUpdate event to do this most likely.

But you haven't told us how you would decide which value to be used.
 
G

Guest

For example, if Retirement is "True" then I would want Net Effect to show -1.
If New Hire is "True" then I would want Net Effect to show 1.

I hope this helps
 
K

Ken Snell [MVP]

But you mention that you have 14 checkboxes. Are all 14 involved in deciding
what the value of Net Effect will be? Or as your reply suggests, just the
two (Retirement and New Hire) dictate the value?

The code is fairly simple for the latter case:

If Me.Retirement.Value = True Then
Me.[Net Effect].Value = -1
ElseIf Me.[New Hire].Value = True Then
Me.[Net Effect].Value = 1
End If

--

Ken Snell
<MS ACCESS MVP>
 
G

Guest

It would be all 14 dictating what the value would be.

They are:

Value would be -1:
Transfer Out
Retirement
Resignation
LOA
Discharge
Suspension
Death
Correction Out
Other Out

Value would be 1:
Transfer In
New Hire
Reinstatement
Correction In
Other In

Can I use the same method you previously explained or is there a more
efficient way of doing this?

Thanks for all your help.


Ken Snell said:
But you mention that you have 14 checkboxes. Are all 14 involved in deciding
what the value of Net Effect will be? Or as your reply suggests, just the
two (Retirement and New Hire) dictate the value?

The code is fairly simple for the latter case:

If Me.Retirement.Value = True Then
Me.[Net Effect].Value = -1
ElseIf Me.[New Hire].Value = True Then
Me.[Net Effect].Value = 1
End If

--

Ken Snell
<MS ACCESS MVP>


WCaloni said:
For example, if Retirement is "True" then I would want Net Effect to
show -1.
If New Hire is "True" then I would want Net Effect to show 1.

I hope this helps
 
K

Ken Snell [MVP]

One approach would be this:

If Me.[Transfer In].Value = True Or _
Me.[New Hire].Value = True Or _
Me.[Reinstatement].Value = True Or _
Me.[Correction In].Value = True Or _
Me.[Other In].Value = True Then
Me.[Net Effect].Value = 1
Else
Me.[Net Effect].Value = -1
End If

--

Ken Snell
<MS ACCESS MVP>

WCaloni said:
It would be all 14 dictating what the value would be.

They are:

Value would be -1:
Transfer Out
Retirement
Resignation
LOA
Discharge
Suspension
Death
Correction Out
Other Out

Value would be 1:
Transfer In
New Hire
Reinstatement
Correction In
Other In

Can I use the same method you previously explained or is there a more
efficient way of doing this?

Thanks for all your help.


Ken Snell said:
But you mention that you have 14 checkboxes. Are all 14 involved in
deciding
what the value of Net Effect will be? Or as your reply suggests, just the
two (Retirement and New Hire) dictate the value?

The code is fairly simple for the latter case:

If Me.Retirement.Value = True Then
Me.[Net Effect].Value = -1
ElseIf Me.[New Hire].Value = True Then
Me.[Net Effect].Value = 1
End If

--

Ken Snell
<MS ACCESS MVP>


WCaloni said:
For example, if Retirement is "True" then I would want Net Effect to
show -1.
If New Hire is "True" then I would want Net Effect to show 1.

I hope this helps


:

Yes, you could use the form's BeforeUpdate event to do this most
likely.

But you haven't told us how you would decide which value to be used.

--

Ken Snell
<MS ACCESS MVP>

I have a database that I am using to track employee activity. My
table/form
includes 14 check boxes, ie: Retirement, Resignation, Transfer In,
New
Hire,
etc.

I have another field that is a "Net Effect" field. I would like
this
field
to automatically populate with a 1 or -1 depending on which box is
checked.
Is this possible? Is there a better way of doing this?

I am not an advanced user by any means, but I can muddle my way
through.

Any help would be appreciated.

Thanks!
 
G

Guest

OK - I put this as code in BeforeUpdate. However, when I check a box,
nothing seems to be happening. What am I doing wrong now?



Ken Snell said:
One approach would be this:

If Me.[Transfer In].Value = True Or _
Me.[New Hire].Value = True Or _
Me.[Reinstatement].Value = True Or _
Me.[Correction In].Value = True Or _
Me.[Other In].Value = True Then
Me.[Net Effect].Value = 1
Else
Me.[Net Effect].Value = -1
End If

--

Ken Snell
<MS ACCESS MVP>

WCaloni said:
It would be all 14 dictating what the value would be.

They are:

Value would be -1:
Transfer Out
Retirement
Resignation
LOA
Discharge
Suspension
Death
Correction Out
Other Out

Value would be 1:
Transfer In
New Hire
Reinstatement
Correction In
Other In

Can I use the same method you previously explained or is there a more
efficient way of doing this?

Thanks for all your help.


Ken Snell said:
But you mention that you have 14 checkboxes. Are all 14 involved in
deciding
what the value of Net Effect will be? Or as your reply suggests, just the
two (Retirement and New Hire) dictate the value?

The code is fairly simple for the latter case:

If Me.Retirement.Value = True Then
Me.[Net Effect].Value = -1
ElseIf Me.[New Hire].Value = True Then
Me.[Net Effect].Value = 1
End If

--

Ken Snell
<MS ACCESS MVP>


For example, if Retirement is "True" then I would want Net Effect to
show -1.
If New Hire is "True" then I would want Net Effect to show 1.

I hope this helps


:

Yes, you could use the form's BeforeUpdate event to do this most
likely.

But you haven't told us how you would decide which value to be used.

--

Ken Snell
<MS ACCESS MVP>

I have a database that I am using to track employee activity. My
table/form
includes 14 check boxes, ie: Retirement, Resignation, Transfer In,
New
Hire,
etc.

I have another field that is a "Net Effect" field. I would like
this
field
to automatically populate with a 1 or -1 depending on which box is
checked.
Is this possible? Is there a better way of doing this?

I am not an advanced user by any means, but I can muddle my way
through.

Any help would be appreciated.

Thanks!
 
K

Ken Snell [MVP]

You didn't say you wanted something to happen *when* you check the box, only
how to set the value as part of saving the record.

If you want to have the value show up as soon as you click a checkbox
(assuming that you're not saving the value of the Net Effect textbox), put
this expression in the ControlSource of the Net Effect textbox:

=IIf([Transfer In].Value = True Or [New Hire].Value = True Or
[Reinstatement].Value = True Or [Correction In].Value = True Or [Other
In].Value = True, 1, -1)

If you're wanting to save the value, then you'll need to run code on the
AfterUpdate event of each checkbox. Create a private subroutine in the
form's module:

Private Sub UpdateNetEffectBox()
If Me.[Transfer In].Value = True Or _
Me.[New Hire].Value = True Or _
Me.[Reinstatement].Value = True Or _
Me.[Correction In].Value = True Or _
Me.[Other In].Value = True Then
Me.[Net Effect].Value = 1
Else
Me.[Net Effect].Value = -1
End If
End Sub

Then put this code on AfterUpdate event of each checkbox (change
Checkboxcontrolname to real name for each checkbox):

Private Sub Checkboxcontrolname_AfterUpdate()
Call UpdateNetEffectBox
End Sub

--

Ken Snell
<MS ACCESS MVP>

WCaloni said:
OK - I put this as code in BeforeUpdate. However, when I check a box,
nothing seems to be happening. What am I doing wrong now?



Ken Snell said:
One approach would be this:

If Me.[Transfer In].Value = True Or _
Me.[New Hire].Value = True Or _
Me.[Reinstatement].Value = True Or _
Me.[Correction In].Value = True Or _
Me.[Other In].Value = True Then
Me.[Net Effect].Value = 1
Else
Me.[Net Effect].Value = -1
End If

--

Ken Snell
<MS ACCESS MVP>

WCaloni said:
It would be all 14 dictating what the value would be.

They are:

Value would be -1:
Transfer Out
Retirement
Resignation
LOA
Discharge
Suspension
Death
Correction Out
Other Out

Value would be 1:
Transfer In
New Hire
Reinstatement
Correction In
Other In

Can I use the same method you previously explained or is there a more
efficient way of doing this?

Thanks for all your help.


:

But you mention that you have 14 checkboxes. Are all 14 involved in
deciding
what the value of Net Effect will be? Or as your reply suggests, just
the
two (Retirement and New Hire) dictate the value?

The code is fairly simple for the latter case:

If Me.Retirement.Value = True Then
Me.[Net Effect].Value = -1
ElseIf Me.[New Hire].Value = True Then
Me.[Net Effect].Value = 1
End If

--

Ken Snell
<MS ACCESS MVP>


For example, if Retirement is "True" then I would want Net Effect to
show -1.
If New Hire is "True" then I would want Net Effect to show 1.

I hope this helps


:

Yes, you could use the form's BeforeUpdate event to do this most
likely.

But you haven't told us how you would decide which value to be
used.

--

Ken Snell
<MS ACCESS MVP>

I have a database that I am using to track employee activity. My
table/form
includes 14 check boxes, ie: Retirement, Resignation, Transfer
In,
New
Hire,
etc.

I have another field that is a "Net Effect" field. I would like
this
field
to automatically populate with a 1 or -1 depending on which box
is
checked.
Is this possible? Is there a better way of doing this?

I am not an advanced user by any means, but I can muddle my way
through.

Any help would be appreciated.

Thanks!
 

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