Hiding a subform under certain conditions

  • Thread starter Thread starter Anne
  • Start date Start date
A

Anne

My jobform comes from the tbljobs and the main field is JobID. There is also
a JobNo field.
When the contractor bids for the job, a jobID is given because its an
autonumber field. When the bid is accepted, a JobNo is assigned by the big
boss, an then the bid becomes a job.
The bid is being tracked by duedate and DueText. I am listing of both Jobs
and Bids on the same form. The bids just do not have a jobNo.

I put the two Due fields into a subform linked to the the main form by
JobId. How can I hide this subform, when the job has a JobNo and make it
visible when there is no jobNo?
Anne
 
Anne said:
My jobform comes from the tbljobs and the main field is JobID. There
is also a JobNo field.
When the contractor bids for the job, a jobID is given because its an
autonumber field. When the bid is accepted, a JobNo is assigned by
the big boss, an then the bid becomes a job.
The bid is being tracked by duedate and DueText. I am listing of both
Jobs and Bids on the same form. The bids just do not have a jobNo.

I put the two Due fields into a subform linked to the the main form by
JobId. How can I hide this subform, when the job has a JobNo and make
it visible when there is no jobNo?

You could use code in the main form's current event to hide the subform
is the JobNo field is Null:

'----- start of example code -----
Private Sub Form_Current()

Me.sfDueFields.Visible = IsNull(Me.JobNo)

End Sub
'----- end of example code -----

In the above, you must substitute the name of your subform control --
that is, the control on the main form that displays the subform -- for
"sfDueFields", which is just a name I made up.
 
Thank you, works like a charm.
Anne

Dirk Goldgar said:
You could use code in the main form's current event to hide the subform
is the JobNo field is Null:

'----- start of example code -----
Private Sub Form_Current()

Me.sfDueFields.Visible = IsNull(Me.JobNo)

End Sub
'----- end of example code -----

In the above, you must substitute the name of your subform control --
that is, the control on the main form that displays the subform -- for
"sfDueFields", which is just a name I made up.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Back
Top