Make a Field Visible based on data in 2 other feilds

M

Minal

Hi,
I have this real tricky form that I need to create. The form has a
TaskNumber, TaskLeader, TargetDuedate, DateCompleted, Extension1,
Extension2, Extension3, Extension4, ApprovalOfVP (y/n).

This is how I want the form to work -
When a record is created these feilds area not visible -
Extension1, Extension2, Extension3, Extension4, ApprovalOfVP (y/n).
User enters information for the following -
TaskNumber, TaskLeader, TargetDuedate
leaving the DateCompleted feild visible but empty.

Now I want that
IF TargetDuedate is currentdate and DateCompleted is Null then
Extension1 = Visible (user will then enter Extension1 date)
IF Extension1 Current Date and DateCompleted = Null then Extension2 =
visible
IF Extension2 Currentdate and datecompleted = Null then Extension3 =
Visible
so on and so forth.

Can any one help me please.
 
G

Guest

Set the Visible properties of these controls to No in design view
Extension1, Extension2, Extension3, Extension4, ApprovalOfVP (y/n)

In the form Load Event:
IF Me.TargetDuedate >= Date And IsNull(Me.DateCompleted) Then
Me.Extension1.Visible = True
End If
IF Me.Extension1 >= Date And IsNull(Me.DateCompleted) Then
Me.Extension2.Visible = True
End If

As so on
 
B

Barry Gilbert

Some code:

Private Sub SetExtensionsVisible()
Me.Extension1.Visible=(TargetDueDate = Date And
IsNull(DateCompleted))
Me.Extension2.Visible = (Extension1 = Date And
IsNull(DateCompleted))
Me.Extension3.Visible = (Extension2 = Date And
IsNull(DateCompleted))
End Sub

Then, in the AfterUpdate events of Extension1, Extension2, and
DateCompleted put:

SetExtensionsVisible

You might need to tweak control names and set some to null, but this
should work.

HTH,
Barry
 
M

Minal

Hi
Thanks for the help I did what you suggested -

I put the code in the foad event

IF Me.TargetDuedate < Date And IsNull(Me.DateCompleted) Then
Me.Extension1.Visible = True
End If
IF Me.Extension1 < Date And IsNull(Me.DateCompleted) Then
Me.Extension2.Visible = True

and so on

here is what happens

Say there are 4 tasks with the following due dates

Task 1 -- 4/6/06
Task 2 - 4/6/06
Task3 - 4/8/06
Task 4 - 4/12/06

On 4/7/06 Extension 1 becomes visible for Task1 and task 2 records the
user enters Extension1 date for task 1 as 4/9/06

But

Extension 1 becomes visible for Task 3 and Task 4 records even if the
target duedate is > than the current date


Then
if Extension 2 is set at 4/8/06 for the task 1 and 2 and 4/11/06 for
task 3

on 4/8/06 user enters DateCompleted for Task 3 as 4/8/06

On 4/9/06 the the record for task 3 shows the extension 3 as visible
and extension 3 is visible for all the records

I want the extensions to be visible only if the tragetduedate or the
extensiondate is less than the current date and the datecompleted feild
is null.

any suggestions on how to proceed.
 
M

Minal

Hi Barry,

Thankyou for the code but one question (pardon me for my ignorance)
where do I put this code


Private Sub SetExtensionsVisible()
Me.Extension1.Visible=(TargetDueDate < Date And
IsNull(DateCompleted))
Me.Extension2.Visible = (Extension1 < Date And
IsNull(DateCompleted))
Me.Extension3.Visible = (Extension2 < Date And
IsNull(DateCompleted))
End Sub


Thanks for the help.
 
B

Barry Gilbert

This is an "unbound" routine. You can just paste it anywhere in the
form's code module.
 

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