On Current

G

Guest

I have this right now

rivate Sub Form_Current()
If [Late] = True Then
[Date suppose to be in].Visible = True
Else
[Date suppose to be in].Visible = False
End If
If [Late] = True Then
[Date Received].Visible = True
Else
[Date Received].Visible = False
End If
If [Late] = True Then
[Date appeal letter sent out].Visible = True
Else
[Date appeal letter sent out].Visible = False
End If
If [Late] = True Then
[Late Approved].Visible = True
Else
[Late Approved].Visible = False
End If
If [Late] = True Then
[Late Denied].Visible = True
Else
[Late Denied].Visible = False
End If

If [Late] = True Then
[Late Approve Date].Visible = True
Else
[Late Approve Date].Visible = False
End If

If Abs([Diff]) >= 10 Then
[Print Diff Letter].Visible = True
Else
[Print Diff Letter].Visible = False
End If
If [Late] = True Then
[Print Late Letter].Visible = True
Else
[Print Late Letter].Visible = False
End If

All of it it works except for these two

If Abs([Diff]) >= 10 Then
[Print Diff Letter].Visible = True
Else
[Print Diff Letter].Visible = False
End If
If [Late] = True Then
[Print Late Letter].Visible = True
Else
[Print Late Letter].Visible = False
End If

These are both command buttons. Is there a differnt way to code it with a
command button?
If I go to the next record and then return to the current record the command
buttons are there. Just not when I click on the the check box for late.
Thanks
Chey
 
G

Guest

Chey,

No, command buttons have a Visible property that you set in the same way as
any other control. But your code is in the On Current event, which is called
only when you arrive on a new record. The code also needs to be placed in
Late's AfterUpdate event, so that if the user changes the value, the
visibilities get toggled.

Also, you can make your code more compact and readable by testing Late's
value only once:

If [Late] = True Then

[Date suppose to be in].Visible = True
[Date Received].Visible = True
[Date appeal letter sent out].Visible = True
[Late Approved].Visible = True
[Late Denied].Visible = True
[Late Approve Date].Visible = True
[Print Late Letter].Visible = True

Else

[Date suppose to be in].Visible = False
[Date Received].Visible = False
[Date appeal letter sent out].Visible = False
[Late Approved].Visible = False
[Late Denied].Visible = False
[Late Approve Date].Visible = False
[Print Late Letter].Visible = False

End If

If Abs([Diff]) >= 10 Then
[Print Diff Letter].Visible = True
Else
[Print Diff Letter].Visible = False
End If

Hope that helps.
Sprinks
 
G

Guest

The Print Late letter works but not the print diff leter.
I put it under On current and after update.
Any other suggestions?

Sprinks said:
Chey,

No, command buttons have a Visible property that you set in the same way as
any other control. But your code is in the On Current event, which is called
only when you arrive on a new record. The code also needs to be placed in
Late's AfterUpdate event, so that if the user changes the value, the
visibilities get toggled.

Also, you can make your code more compact and readable by testing Late's
value only once:

If [Late] = True Then

[Date suppose to be in].Visible = True
[Date Received].Visible = True
[Date appeal letter sent out].Visible = True
[Late Approved].Visible = True
[Late Denied].Visible = True
[Late Approve Date].Visible = True
[Print Late Letter].Visible = True

Else

[Date suppose to be in].Visible = False
[Date Received].Visible = False
[Date appeal letter sent out].Visible = False
[Late Approved].Visible = False
[Late Denied].Visible = False
[Late Approve Date].Visible = False
[Print Late Letter].Visible = False

End If

If Abs([Diff]) >= 10 Then
[Print Diff Letter].Visible = True
Else
[Print Diff Letter].Visible = False
End If

Hope that helps.
Sprinks


Chey said:
I have this right now

rivate Sub Form_Current()
If [Late] = True Then
[Date suppose to be in].Visible = True
Else
[Date suppose to be in].Visible = False
End If
If [Late] = True Then
[Date Received].Visible = True
Else
[Date Received].Visible = False
End If
If [Late] = True Then
[Date appeal letter sent out].Visible = True
Else
[Date appeal letter sent out].Visible = False
End If
If [Late] = True Then
[Late Approved].Visible = True
Else
[Late Approved].Visible = False
End If
If [Late] = True Then
[Late Denied].Visible = True
Else
[Late Denied].Visible = False
End If

If [Late] = True Then
[Late Approve Date].Visible = True
Else
[Late Approve Date].Visible = False
End If

If Abs([Diff]) >= 10 Then
[Print Diff Letter].Visible = True
Else
[Print Diff Letter].Visible = False
End If
If [Late] = True Then
[Print Late Letter].Visible = True
Else
[Print Late Letter].Visible = False
End If

All of it it works except for these two

If Abs([Diff]) >= 10 Then
[Print Diff Letter].Visible = True
Else
[Print Diff Letter].Visible = False
End If
If [Late] = True Then
[Print Late Letter].Visible = True
Else
[Print Late Letter].Visible = False
End If

These are both command buttons. Is there a differnt way to code it with a
command button?
If I go to the next record and then return to the current record the command
buttons are there. Just not when I click on the the check box for late.
Thanks
Chey
 
G

Guest

Chey,

If PrintDiffLetter.Visible is not toggling to True, then either

Abs([Diff]) >= 10 is evaluating to false, or there is a problem with your
reference. Try:

If Abs([Diff]) >= 10 Then
MsgBox "Absolute value of Diff is >=10."
[Print Diff Letter].Visible = True
Else
[Print Diff Letter].Visible = False
MsgBox "Absolute value of Diff is <10."
End If

If it displays the first MsgBox, check the name property of the command
button. It is likely different from your reference.

If it displays the second MsgBox, check the name property of the Diff control.

Hope that helps.
Sprinks




Chey said:
The Print Late letter works but not the print diff leter.
I put it under On current and after update.
Any other suggestions?

Sprinks said:
Chey,

No, command buttons have a Visible property that you set in the same way as
any other control. But your code is in the On Current event, which is called
only when you arrive on a new record. The code also needs to be placed in
Late's AfterUpdate event, so that if the user changes the value, the
visibilities get toggled.

Also, you can make your code more compact and readable by testing Late's
value only once:

If [Late] = True Then

[Date suppose to be in].Visible = True
[Date Received].Visible = True
[Date appeal letter sent out].Visible = True
[Late Approved].Visible = True
[Late Denied].Visible = True
[Late Approve Date].Visible = True
[Print Late Letter].Visible = True

Else

[Date suppose to be in].Visible = False
[Date Received].Visible = False
[Date appeal letter sent out].Visible = False
[Late Approved].Visible = False
[Late Denied].Visible = False
[Late Approve Date].Visible = False
[Print Late Letter].Visible = False

End If

If Abs([Diff]) >= 10 Then
[Print Diff Letter].Visible = True
Else
[Print Diff Letter].Visible = False
End If

Hope that helps.
Sprinks


Chey said:
I have this right now

rivate Sub Form_Current()
If [Late] = True Then
[Date suppose to be in].Visible = True
Else
[Date suppose to be in].Visible = False
End If
If [Late] = True Then
[Date Received].Visible = True
Else
[Date Received].Visible = False
End If
If [Late] = True Then
[Date appeal letter sent out].Visible = True
Else
[Date appeal letter sent out].Visible = False
End If
If [Late] = True Then
[Late Approved].Visible = True
Else
[Late Approved].Visible = False
End If
If [Late] = True Then
[Late Denied].Visible = True
Else
[Late Denied].Visible = False
End If

If [Late] = True Then
[Late Approve Date].Visible = True
Else
[Late Approve Date].Visible = False
End If

If Abs([Diff]) >= 10 Then
[Print Diff Letter].Visible = True
Else
[Print Diff Letter].Visible = False
End If
If [Late] = True Then
[Print Late Letter].Visible = True
Else
[Print Late Letter].Visible = False
End If

All of it it works except for these two

If Abs([Diff]) >= 10 Then
[Print Diff Letter].Visible = True
Else
[Print Diff Letter].Visible = False
End If
If [Late] = True Then
[Print Late Letter].Visible = True
Else
[Print Late Letter].Visible = False
End If

These are both command buttons. Is there a differnt way to code it with a
command button?
If I go to the next record and then return to the current record the command
buttons are there. Just not when I click on the the check box for late.
Thanks
Chey
 
B

BruceM

The form's Current event runs when you first go to the record. You would
need to run the code in the After Update event for the Late check box, as
well as the Current event. One way to do that is to create a public sub
that contains the code. In the VBA window, click Insert > Procedure, and
follow the prompts to create a Public Sub. Give it a tidy name such as
ShowIfLate. Then, in the check box After Update event and the form's
Current event, just use the line:
Call ShowIfLate. If you need to modify the code you just modify it once in
the Public sub, and not separately in each event.

You can have more than one Then or Else in an If statement:

If [Late] = True Then
[Date suppose to be in].Visible = True
[Date Received].Visible = True
Else
[Date suppose to be in].Visible = False
[Date Received].Visible = False
End If

I showed just two, but you can have as many as you want.

Make sure your text boxes have different names than the fields to which they
are bound. Access gives text boxes the same name as the field by default,
which can cause problems when Access isn't sure which one you mean. I
usually put txt in front of the field name to make the text box name, but
the details are up to you.
 
B

Bill Mosca, MS Access MVP

Chey

Check your spelling to make sure it is correct for the 2 buttons. I always
use Me in front of a control name. If you do that a list of properties,
methods and controls will pop up.

Type Me.P

As soon as you type the dot, an intellisense list will pop up. When you
type the P, the list will focus on the first item starting with P. This
should make it easier to find your button's name.

I also suggest you do not use spaces in control names. While square brackets
around the name make it OK, it can lead to mistakes.

--
Bill Mosca, MS Access MVP


Chey said:
The Print Late letter works but not the print diff leter.
I put it under On current and after update.
Any other suggestions?

Sprinks said:
Chey,

No, command buttons have a Visible property that you set in the same way
as
any other control. But your code is in the On Current event, which is
called
only when you arrive on a new record. The code also needs to be placed
in
Late's AfterUpdate event, so that if the user changes the value, the
visibilities get toggled.

Also, you can make your code more compact and readable by testing Late's
value only once:

If [Late] = True Then

[Date suppose to be in].Visible = True
[Date Received].Visible = True
[Date appeal letter sent out].Visible = True
[Late Approved].Visible = True
[Late Denied].Visible = True
[Late Approve Date].Visible = True
[Print Late Letter].Visible = True

Else

[Date suppose to be in].Visible = False
[Date Received].Visible = False
[Date appeal letter sent out].Visible = False
[Late Approved].Visible = False
[Late Denied].Visible = False
[Late Approve Date].Visible = False
[Print Late Letter].Visible = False

End If

If Abs([Diff]) >= 10 Then
[Print Diff Letter].Visible = True
Else
[Print Diff Letter].Visible = False
End If

Hope that helps.
Sprinks


Chey said:
I have this right now

rivate Sub Form_Current()
If [Late] = True Then
[Date suppose to be in].Visible = True
Else
[Date suppose to be in].Visible = False
End If
If [Late] = True Then
[Date Received].Visible = True
Else
[Date Received].Visible = False
End If
If [Late] = True Then
[Date appeal letter sent out].Visible = True
Else
[Date appeal letter sent out].Visible = False
End If
If [Late] = True Then
[Late Approved].Visible = True
Else
[Late Approved].Visible = False
End If
If [Late] = True Then
[Late Denied].Visible = True
Else
[Late Denied].Visible = False
End If

If [Late] = True Then
[Late Approve Date].Visible = True
Else
[Late Approve Date].Visible = False
End If

If Abs([Diff]) >= 10 Then
[Print Diff Letter].Visible = True
Else
[Print Diff Letter].Visible = False
End If
If [Late] = True Then
[Print Late Letter].Visible = True
Else
[Print Late Letter].Visible = False
End If

All of it it works except for these two

If Abs([Diff]) >= 10 Then
[Print Diff Letter].Visible = True
Else
[Print Diff Letter].Visible = False
End If
If [Late] = True Then
[Print Late Letter].Visible = True
Else
[Print Late Letter].Visible = False
End If

These are both command buttons. Is there a differnt way to code it
with a
command button?
If I go to the next record and then return to the current record the
command
buttons are there. Just not when I click on the the check box for
late.
Thanks
Chey
 

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