Hide a subform if control value =

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

Hi All

I'm using Access XP.

I want to hide a subform.

I have a form [Alunos] which has two subforms [Alunoslist] (in table format0
and [Alunosdetails].

When I click on a name in [Alunoslist] it automatically shows the details of
that student in [Alunodetails].

[Alunosdetails] also has a subform [Payments] which is shown as a table. I
want [Payments] to be hidden when a control on [Alunosdetails] has the text
value "Não".

Any ideas would be really appreciated.

Jeff
 
You can test almost anything you like then use

forms![MainFormName]![SubFormName].visible = false

I have used this to show/hide information based on a users access level
(user/Administrator) etc.

HTH
Mal.
 
Thanks for your help, Mal

I have this code on the Mainform:

Option Compare Database

Private Sub Form_Current()
'Find the value of the control Atívo
If Me.AlunosDetails!Atívo = "Não" Then
'When the value is não then hide the subform Payments for that record
Forms![Alunos]![Alunosdetails]![Payments].Visible = False
Else
Forms![Alunos]![Alunosdetails]![Payments].Visible = True
End If
End Sub


Private Sub txtCódigo_AfterUpdate()
' Encontrar o registro que coincide com o controle.
Dim RS As Object

Set RS = Me.Recordset.Clone
RS.findfirst "[txtCódigo] = " & Str(Nz(Me![Código], 0))
If Not RS.EOF Then Me.Bookmark = RS.Bookmark

End Sub

The first code 'Private Sub Form_Current()' does almost what I want it to.
When I open the form for the first time, it hides or shows the subform
[payments] inside subform 2 [Alunosdetails].

But when I click on a name in the subform 1 [Alunoslist], it does not hide
or show the subform [payments], the state of visible remains like the first
record shown when the mainform is opened.

I've tried using the AfterUpdate and Load events but still the same problem.

Any ideas about this are really welcome...

Jeff


Mal Reeve said:
You can test almost anything you like then use

forms![MainFormName]![SubFormName].visible = false

I have used this to show/hide information based on a users access level
(user/Administrator) etc.

HTH
Mal.


Jeff said:
Hi All

I'm using Access XP.

I want to hide a subform.

I have a form [Alunos] which has two subforms [Alunoslist] (in table format0
and [Alunosdetails].

When I click on a name in [Alunoslist] it automatically shows the
details
of
that student in [Alunodetails].

[Alunosdetails] also has a subform [Payments] which is shown as a table. I
want [Payments] to be hidden when a control on [Alunosdetails] has the text
value "Não".

Any ideas would be really appreciated.

Jeff
 
you have your code on the wrong form's event, Jeff. delete all the lines of
code beginning with

Private Sub Form_Current()
and ending with the *first* line that says
End Sub

from the main form's code window. go to the subform's code window and paste
in the following code instead, as

Private Sub Form_Current()

Me!Payments.Visible = Not (Me!Atívo = "Não")

End Sub

Private Sub Atívo_AfterUpdate()

Me!Payments.Visible = Not (Me!Atívo = "Não")

End Sub

btw, suggest you turn on the Option Explicit requirement. to do this, go to
the code window and click on Tools, Options, Editor tab. put a checkmark in
the box next to Require Variable Declaration.

hth


Jeff said:
Thanks for your help, Mal

I have this code on the Mainform:

Option Compare Database

Private Sub Form_Current()
'Find the value of the control Atívo
If Me.AlunosDetails!Atívo = "Não" Then
'When the value is não then hide the subform Payments for that record
Forms![Alunos]![Alunosdetails]![Payments].Visible = False
Else
Forms![Alunos]![Alunosdetails]![Payments].Visible = True
End If
End Sub


Private Sub txtCódigo_AfterUpdate()
' Encontrar o registro que coincide com o controle.
Dim RS As Object

Set RS = Me.Recordset.Clone
RS.findfirst "[txtCódigo] = " & Str(Nz(Me![Código], 0))
If Not RS.EOF Then Me.Bookmark = RS.Bookmark

End Sub

The first code 'Private Sub Form_Current()' does almost what I want it to.
When I open the form for the first time, it hides or shows the subform
[payments] inside subform 2 [Alunosdetails].

But when I click on a name in the subform 1 [Alunoslist], it does not hide
or show the subform [payments], the state of visible remains like the first
record shown when the mainform is opened.

I've tried using the AfterUpdate and Load events but still the same problem.

Any ideas about this are really welcome...

Jeff


Mal Reeve said:
You can test almost anything you like then use

forms![MainFormName]![SubFormName].visible = false

I have used this to show/hide information based on a users access level
(user/Administrator) etc.

HTH
Mal.


Jeff said:
Hi All

I'm using Access XP.

I want to hide a subform.

I have a form [Alunos] which has two subforms [Alunoslist] (in table format0
and [Alunosdetails].

When I click on a name in [Alunoslist] it automatically shows the
details
of
that student in [Alunodetails].

[Alunosdetails] also has a subform [Payments] which is shown as a
table.
I
want [Payments] to be hidden when a control on [Alunosdetails] has the text
value "Não".

Any ideas would be really appreciated.

Jeff
 
Thanks Tina

I did what you asked, but I'm getting an error message when the form opens.
My Access is in Portugese so the exact wording I don't know but..

The expression Current that you used as a property event caused the
following problem: a problem occurred when Access tried to communicate with
the OLE control or the ActiveX. Maybe the expression did not result in a
function, macro or procedure.

Any more ideas?
Thanks for the advice

Jeff

tina said:
you have your code on the wrong form's event, Jeff. delete all the lines of
code beginning with

Private Sub Form_Current()
and ending with the *first* line that says
End Sub

from the main form's code window. go to the subform's code window and paste
in the following code instead, as

Private Sub Form_Current()

Me!Payments.Visible = Not (Me!Atívo = "Não")

End Sub

Private Sub Atívo_AfterUpdate()

Me!Payments.Visible = Not (Me!Atívo = "Não")

End Sub

btw, suggest you turn on the Option Explicit requirement. to do this, go to
the code window and click on Tools, Options, Editor tab. put a checkmark in
the box next to Require Variable Declaration.

hth


Jeff said:
Thanks for your help, Mal

I have this code on the Mainform:

Option Compare Database

Private Sub Form_Current()
'Find the value of the control Atívo
If Me.AlunosDetails!Atívo = "Não" Then
'When the value is não then hide the subform Payments for that record
Forms![Alunos]![Alunosdetails]![Payments].Visible = False
Else
Forms![Alunos]![Alunosdetails]![Payments].Visible = True
End If
End Sub


Private Sub txtCódigo_AfterUpdate()
' Encontrar o registro que coincide com o controle.
Dim RS As Object

Set RS = Me.Recordset.Clone
RS.findfirst "[txtCódigo] = " & Str(Nz(Me![Código], 0))
If Not RS.EOF Then Me.Bookmark = RS.Bookmark

End Sub

The first code 'Private Sub Form_Current()' does almost what I want it to.
When I open the form for the first time, it hides or shows the subform
[payments] inside subform 2 [Alunosdetails].

But when I click on a name in the subform 1 [Alunoslist], it does not hide
or show the subform [payments], the state of visible remains like the first
record shown when the mainform is opened.

I've tried using the AfterUpdate and Load events but still the same problem.

Any ideas about this are really welcome...

Jeff


Mal Reeve said:
You can test almost anything you like then use

forms![MainFormName]![SubFormName].visible = false

I have used this to show/hide information based on a users access level
(user/Administrator) etc.

HTH
Mal.


Hi All

I'm using Access XP.

I want to hide a subform.

I have a form [Alunos] which has two subforms [Alunoslist] (in table
format0
and [Alunosdetails].

When I click on a name in [Alunoslist] it automatically shows the details
of
that student in [Alunodetails].

[Alunosdetails] also has a subform [Payments] which is shown as a
table.
I
want [Payments] to be hidden when a control on [Alunosdetails] has the
text
value "Não".

Any ideas would be really appreciated.

Jeff
 
well, let's try compiling the code. in the subform's code window, click
Debug, Compile. if you don't get an error message and the Compile option
greys out, then it's okay. if you get an error message, fix the problem if
you can and if not, post back with details.
another thing, if you're using A2000 or later, turn off the Name AutoCorrect
feature. to do this, go to the database window (*not* the code window) and
click Tools, Options, General tab. remove the checkmark from the box next to
"Track name AutoCorrect info". then click the Apply button, and then OK.
then compact the database.
also, when you open the sub form [AlunosDetails] *by itself in design view*
and open the Properties window, do you see [Event Procedure] in the window
next to the On Current event in the form's Properties box?
if you click the "three-dots" (ellipsis) box at far right, does it go to the
correct procedure?
check all of the above and post back with results. btw, it's late Saturday
evening here, so i probably won't recheck the thread until tomorrow.


Jeff said:
Thanks Tina

I did what you asked, but I'm getting an error message when the form opens.
My Access is in Portugese so the exact wording I don't know but..

The expression Current that you used as a property event caused the
following problem: a problem occurred when Access tried to communicate with
the OLE control or the ActiveX. Maybe the expression did not result in a
function, macro or procedure.

Any more ideas?
Thanks for the advice

Jeff

tina said:
you have your code on the wrong form's event, Jeff. delete all the lines of
code beginning with

Private Sub Form_Current()
and ending with the *first* line that says
End Sub

from the main form's code window. go to the subform's code window and paste
in the following code instead, as

Private Sub Form_Current()

Me!Payments.Visible = Not (Me!Atívo = "Não")

End Sub

Private Sub Atívo_AfterUpdate()

Me!Payments.Visible = Not (Me!Atívo = "Não")

End Sub

btw, suggest you turn on the Option Explicit requirement. to do this, go to
the code window and click on Tools, Options, Editor tab. put a checkmark in
the box next to Require Variable Declaration.

hth


Jeff said:
Thanks for your help, Mal

I have this code on the Mainform:

Option Compare Database

Private Sub Form_Current()
'Find the value of the control Atívo
If Me.AlunosDetails!Atívo = "Não" Then
'When the value is não then hide the subform Payments for that record
Forms![Alunos]![Alunosdetails]![Payments].Visible = False
Else
Forms![Alunos]![Alunosdetails]![Payments].Visible = True
End If
End Sub


Private Sub txtCódigo_AfterUpdate()
' Encontrar o registro que coincide com o controle.
Dim RS As Object

Set RS = Me.Recordset.Clone
RS.findfirst "[txtCódigo] = " & Str(Nz(Me![Código], 0))
If Not RS.EOF Then Me.Bookmark = RS.Bookmark

End Sub

The first code 'Private Sub Form_Current()' does almost what I want it to.
When I open the form for the first time, it hides or shows the subform
[payments] inside subform 2 [Alunosdetails].

But when I click on a name in the subform 1 [Alunoslist], it does not hide
or show the subform [payments], the state of visible remains like the first
record shown when the mainform is opened.

I've tried using the AfterUpdate and Load events but still the same problem.

Any ideas about this are really welcome...

Jeff


Mal Reeve <[email protected]> escreveu nas notícias de
mensagem:[email protected]...
You can test almost anything you like then use

forms![MainFormName]![SubFormName].visible = false

I have used this to show/hide information based on a users access level
(user/Administrator) etc.

HTH
Mal.


Hi All

I'm using Access XP.

I want to hide a subform.

I have a form [Alunos] which has two subforms [Alunoslist] (in table
format0
and [Alunosdetails].

When I click on a name in [Alunoslist] it automatically shows the
details
of
that student in [Alunodetails].

[Alunosdetails] also has a subform [Payments] which is shown as a table.
I
want [Payments] to be hidden when a control on [Alunosdetails] has the
text
value "Não".

Any ideas would be really appreciated.

Jeff
 
Tina, you're an Angel...

But I've followed your instuctions to the T and no luck, still getting that
error message.

Any more ideas?

Jeff

tina said:
well, let's try compiling the code. in the subform's code window, click
Debug, Compile. if you don't get an error message and the Compile option
greys out, then it's okay. if you get an error message, fix the problem if
you can and if not, post back with details.
another thing, if you're using A2000 or later, turn off the Name AutoCorrect
feature. to do this, go to the database window (*not* the code window) and
click Tools, Options, General tab. remove the checkmark from the box next to
"Track name AutoCorrect info". then click the Apply button, and then OK.
then compact the database.
also, when you open the sub form [AlunosDetails] *by itself in design view*
and open the Properties window, do you see [Event Procedure] in the window
next to the On Current event in the form's Properties box?
if you click the "three-dots" (ellipsis) box at far right, does it go to the
correct procedure?
check all of the above and post back with results. btw, it's late Saturday
evening here, so i probably won't recheck the thread until tomorrow.


Jeff said:
Thanks Tina

I did what you asked, but I'm getting an error message when the form opens.
My Access is in Portugese so the exact wording I don't know but..

The expression Current that you used as a property event caused the
following problem: a problem occurred when Access tried to communicate with
the OLE control or the ActiveX. Maybe the expression did not result in a
function, macro or procedure.

Any more ideas?
Thanks for the advice

Jeff

tina said:
you have your code on the wrong form's event, Jeff. delete all the
lines
of
code beginning with

Private Sub Form_Current()
and ending with the *first* line that says
End Sub

from the main form's code window. go to the subform's code window and paste
in the following code instead, as

Private Sub Form_Current()

Me!Payments.Visible = Not (Me!Atívo = "Não")

End Sub

Private Sub Atívo_AfterUpdate()

Me!Payments.Visible = Not (Me!Atívo = "Não")

End Sub

btw, suggest you turn on the Option Explicit requirement. to do this,
go
to
the code window and click on Tools, Options, Editor tab. put a
checkmark
in
the box next to Require Variable Declaration.

hth


Thanks for your help, Mal

I have this code on the Mainform:

Option Compare Database

Private Sub Form_Current()
'Find the value of the control Atívo
If Me.AlunosDetails!Atívo = "Não" Then
'When the value is não then hide the subform Payments for that record
Forms![Alunos]![Alunosdetails]![Payments].Visible = False
Else
Forms![Alunos]![Alunosdetails]![Payments].Visible = True
End If
End Sub


Private Sub txtCódigo_AfterUpdate()
' Encontrar o registro que coincide com o controle.
Dim RS As Object

Set RS = Me.Recordset.Clone
RS.findfirst "[txtCódigo] = " & Str(Nz(Me![Código], 0))
If Not RS.EOF Then Me.Bookmark = RS.Bookmark

End Sub

The first code 'Private Sub Form_Current()' does almost what I want
it
to.
When I open the form for the first time, it hides or shows the subform
[payments] inside subform 2 [Alunosdetails].

But when I click on a name in the subform 1 [Alunoslist], it does
not
hide
or show the subform [payments], the state of visible remains like the
first
record shown when the mainform is opened.

I've tried using the AfterUpdate and Load events but still the same
problem.

Any ideas about this are really welcome...

Jeff


Mal Reeve <[email protected]> escreveu nas notícias de
mensagem:[email protected]...
You can test almost anything you like then use

forms![MainFormName]![SubFormName].visible = false

I have used this to show/hide information based on a users access level
(user/Administrator) etc.

HTH
Mal.


Hi All

I'm using Access XP.

I want to hide a subform.

I have a form [Alunos] which has two subforms [Alunoslist] (in table
format0
and [Alunosdetails].

When I click on a name in [Alunoslist] it automatically shows the
details
of
that student in [Alunodetails].

[Alunosdetails] also has a subform [Payments] which is shown as a
table.
I
want [Payments] to be hidden when a control on [Alunosdetails]
has
the
text
value "Não".

Any ideas would be really appreciated.

Jeff
 
it's possible your db is corrupted. try this: close the db. open a brand
new db in Access. immediately go to Tools, Options, General tab and remove
the checkmark from the box next to "Track name AutoCorrect info". then click
the Apply button, and then OK.
next, click File, Get Data, Import and import all the objects from your
original database. compact the database, and then try opening your form.
i hope this works, because that's the end of my list of ideas....unless the
code did not compile when you ran Debug, Compile - and you forgot to mention
it?
(btw, it's really late now, so i definitely won't be back until sunday
5/23 - late morning or early afternoon!)


Jeff said:
Tina, you're an Angel...

But I've followed your instuctions to the T and no luck, still getting that
error message.

Any more ideas?

Jeff

tina said:
well, let's try compiling the code. in the subform's code window, click
Debug, Compile. if you don't get an error message and the Compile option
greys out, then it's okay. if you get an error message, fix the problem if
you can and if not, post back with details.
another thing, if you're using A2000 or later, turn off the Name AutoCorrect
feature. to do this, go to the database window (*not* the code window) and
click Tools, Options, General tab. remove the checkmark from the box
next
to
"Track name AutoCorrect info". then click the Apply button, and then OK.
then compact the database.
also, when you open the sub form [AlunosDetails] *by itself in design view*
and open the Properties window, do you see [Event Procedure] in the window
next to the On Current event in the form's Properties box?
if you click the "three-dots" (ellipsis) box at far right, does it go to the
correct procedure?
check all of the above and post back with results. btw, it's late Saturday
evening here, so i probably won't recheck the thread until tomorrow.


Jeff said:
Thanks Tina

I did what you asked, but I'm getting an error message when the form opens.
My Access is in Portugese so the exact wording I don't know but..

The expression Current that you used as a property event caused the
following problem: a problem occurred when Access tried to communicate with
the OLE control or the ActiveX. Maybe the expression did not result in a
function, macro or procedure.

Any more ideas?
Thanks for the advice

Jeff

tina <[email protected]> escreveu nas notícias de
mensagem:[email protected]...
you have your code on the wrong form's event, Jeff. delete all the lines
of
code beginning with

Private Sub Form_Current()
and ending with the *first* line that says
End Sub

from the main form's code window. go to the subform's code window and
paste
in the following code instead, as

Private Sub Form_Current()

Me!Payments.Visible = Not (Me!Atívo = "Não")

End Sub

Private Sub Atívo_AfterUpdate()

Me!Payments.Visible = Not (Me!Atívo = "Não")

End Sub

btw, suggest you turn on the Option Explicit requirement. to do
this,
go
to
the code window and click on Tools, Options, Editor tab. put a checkmark
in
the box next to Require Variable Declaration.

hth


Thanks for your help, Mal

I have this code on the Mainform:

Option Compare Database

Private Sub Form_Current()
'Find the value of the control Atívo
If Me.AlunosDetails!Atívo = "Não" Then
'When the value is não then hide the subform Payments for that record
Forms![Alunos]![Alunosdetails]![Payments].Visible = False
Else
Forms![Alunos]![Alunosdetails]![Payments].Visible = True
End If
End Sub


Private Sub txtCódigo_AfterUpdate()
' Encontrar o registro que coincide com o controle.
Dim RS As Object

Set RS = Me.Recordset.Clone
RS.findfirst "[txtCódigo] = " & Str(Nz(Me![Código], 0))
If Not RS.EOF Then Me.Bookmark = RS.Bookmark

End Sub

The first code 'Private Sub Form_Current()' does almost what I
want
it
to.
When I open the form for the first time, it hides or shows the subform
[payments] inside subform 2 [Alunosdetails].

But when I click on a name in the subform 1 [Alunoslist], it does not
hide
or show the subform [payments], the state of visible remains like the
first
record shown when the mainform is opened.

I've tried using the AfterUpdate and Load events but still the same
problem.

Any ideas about this are really welcome...

Jeff


Mal Reeve <[email protected]> escreveu nas notícias de
mensagem:[email protected]...
You can test almost anything you like then use

forms![MainFormName]![SubFormName].visible = false

I have used this to show/hide information based on a users access
level
(user/Administrator) etc.

HTH
Mal.


Hi All

I'm using Access XP.

I want to hide a subform.

I have a form [Alunos] which has two subforms [Alunoslist] (in table
format0
and [Alunosdetails].

When I click on a name in [Alunoslist] it automatically shows the
details
of
that student in [Alunodetails].

[Alunosdetails] also has a subform [Payments] which is shown
as
a
table.
I
want [Payments] to be hidden when a control on [Alunosdetails] has
the
text
value "Não".

Any ideas would be really appreciated.

Jeff
 
Tina...

I followed the instructions and Bingo! I put in the original instructions
you gave me and it works just fine.

Thanks for all your help, it's really appreciated.

Jeff
 
Back
Top