Hiding Controls on a form based on query results

J

John Castle

I have a form with multiple controls on. Some of the
controls are not relevant to some of the records displayed.
What do I have to write in the Oncurrent property in order
to make the controls invisible under certain criteria?
 
T

Trias

Hi,
in your case i'll create a Function called ENABLECONTROL which gets call from OnCurrent event.

Private Sub Form_Current()
if NOT me.newrecord than
Select Case me.CriteriaControl.Value
Case Value1
Call ENABLECONTROL(TRUE, FALSE, TRUE)
case Value2
Call ENABLECONTROL(FALSE, TRUE, TRUE)
else
end select
end if
End Sub

Function ENABLECONTROL(bT1 as boolean, bT2 as boolean, bT3 as boolean,........,bTn as boolean)
with me
.txtT1.Enabled = bT1
.txtT2.Enabled = bT2
.txtT3.Enabled = bT3
-
-
.txtT4.enabled = bTn
end with
End function

HTH
 
G

Guest

use an if statement to check the record. If you have
field in your record table that distinguishes between one
type of record and another type of record, the reason for
having un-needed controls, the all you have to do is
check for the flag. IE,
IF [type] = C then
textbox.visible = false
combobox.visible=false
textbox2.visible=true
Else
textbox.visible = true
combobox.visible=true
textbox2.visible=false
End If
-----Original Message-----
Me![ControlName].Visible = False
-----Original Message-----
I have a form with multiple controls on. Some of the
controls are not relevant to some of the records displayed.
What do I have to write in the Oncurrent property in order
to make the controls invisible under certain criteria?
.
.
 

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