SUBFORM FIElD CONDITIONAL VISIBLE STATE

A

AlipioSequeira

Hello to all forum users.
This is my first entry to this community.

Here is my question.
I have a subform where I have two columns that presente the professional
status of a person.( working, unemployed, liberal professional, looking for
job for a long time, and first time job) to each of these status a code is
attibuted ex: 1; 1.1; 1.2; 2; 2.1 etç.

Now comes my problem.
I have a report, and then a sub form that present a group of people
attending a course.
Course: main report:
Class: sub form.
This report is based in a official national form and instead of havin one
solo column for the persons status, has two. One for status related to
unemployed people, and a second for working people.

On my dta base I created only one fiel to place these codes(1; 1.1 etç)
But in the sub form as I must have two columns I duplicated the field and
gave it different reference names. A1 & A2

The question finaly is:
How do I set a field to be visible deppending on the code displayed.
Kind of if me.A1 < 1 visible = true
and me.A2= visible false.

The code I could work it out I think. My problem is that as I'm mostly
wizard user, programming evadse me.

HELP.

Greatings from Portugal
AlipioSequeira.
PS. I can send prtscreens of form if needed.
 
A

AlipioSequeira

Hello again.

I was trying to place the code below in the controls(text fields)

Private Sub Report_Open(Cancel As Integer)
If Me.Perfil < 0 > 2 Then
Me.Perfil.Visible = True
If Me.Perfil < 2 Then Me.Perfil.Visible = False
End If
If Me.P2 < 2 Then
Me.P2.Visible = True
If Me.Perfil > 2 Then Me.P2.Visible = False
End If
End Sub.

they are in the detail section of the sub report. what am I doing wrong.

Thanks for any hint on this.

AlípioSequeira
 
M

maurice via AccessMonster.com

Well I'm assuming you ar referring to a report using a subreport because in
your thread your are talking about a report and a subform...?

Try placing this in the VBA on the On Open from the report:

if me.perfil < 0 or me.perfil >2 then
me.perfil.visible=true
end if

If Me.P2 < 2 Then
Me.P2.Visible = True
elseIf Me.Perfil > 2 Then
Me.P2.Visible = False
Else
'-> here you should do something when the value is between <2 and >2
End If

Maurice
 
A

AlipioSequeira

PROBLEM SOLVED
Thanks for your help.
Here is how:
Placed this code on the detail section of sub form.
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.P1 > 2 Then
Me.P1.Visible = True
Me.P2.Visible = False
End If

If Me.P2 < 2 Then
Me.P2.Visible = True
Me.P1.Visible = False
End If
End Sub

Greatings from Portugal
AlípioSequeira
 
Top