Visible/Enabled code

David R

I know a few things...
Local time
Today, 16:58
Joined
Oct 23, 2001
Messages
2,632
On my (Continuous Form) subform I have the following code in OnCurrent:
Private Sub Form_Current()
If (Me.DeviceName = "Car Club") Then
Me.LicPlate.Visible = -1
Me.LicPlate.Enabled = -1
Me.VehYear.Visible = -1
Me.VehYear.Enabled = -1
Me.VehModel.Visible = -1
Me.VehModel.Enabled = -1
Else
Me.LicPlate.Visible = 0
Me.LicPlate.Enabled = 0
Me.VehYear.Visible = 0
Me.VehYear.Enabled = 0
Me.VehModel.Visible = 0
Me.VehModel.Enabled = 0
End If
End Sub

However this code makes ALL of the devices change depending on which line has the focus, i.e. if a Car Club has the focus, every entry has the boxes (blank of course for non-car clubs). If a Security Bar has the focus, the extra boxes are invisible for ALL entries.
As you can probably tell, I would like the extra boxes (Dlookup boxes, actually) to only be active on those lines of the continuous subform which are car clubs. Both types are usually present on any particular Main Form entry.

Any suggestions what I am doing wrong?

TIA
David R
 
Thanks Jack. Enabled will have to do then.
 
One suggestion I have to reduce your code is:

Dim blnVisEnabled as Boolean
If (Me.DeviceName = "Car Club") Then
blnVisEnabled = True
Else
blnVisEnabled = False
End if

Me.LicPlate.Visible = blnVisEnabled
Me.LicPlate.Enabled = blnVisEnabled
Me.VehYear.Visible = blnVisEnabled
Me.VehYear.Enabled = blnVisEnabled
Me.VehModel.Visible = blnVisEnabled
Me.VehModel.Enabled = blnVisEnabled

HTH

Ian
 
Thanks Fornatian. I had planned to consolidate my code (with the Tag property) if it worked properly.
 
David,
I had the same problem recently.I did get it to work, but it wasn't pretty.
On the current event of the form, which changes each time the pointer goes to the next record, I saved the values of the pivotal information in a global variable(s). You could save them on the form header or footer in textboxes that you make non-visible. I enforced the enabled look by putting null values in the table cells. This worked great for the checkboxes and such. You also might use the conditional formatting feature if you have combo boxes. Mine were mainly checkboxes and a few textboxes.
You can make it work, but it takes some code. I keep thinking that there is a control collection that I could use. Let me know if you find out something to make this work more elegant.
 

Users who are viewing this thread

Back
Top Bottom