TheSwamp

Code Red => VB(A) => Topic started by: Columbia on November 24, 2004, 11:30:55 AM

Title: Testing for control type
Post by: Columbia on November 24, 2004, 11:30:55 AM
Is there anyway to test for what control type I pass to a variable?

As in this pseudocode:  

1.) pass generic control to function as a Variant.
2.) test for type of control (i.e. textbox, button, listbox, etc...) <-my question
3.) toggle the enable property.


Any body have any ideas???
Title: Testing for control type
Post by: hendie on November 24, 2004, 11:40:27 AM
straight from the Acad help
Code: [Select]
' Call SetTextBoxProperties procedure.
SetTextBoxProperties Me

Sub SetTextBoxProperties(frm As Form)
Dim ctl As Control

' Enumerate Controls collection.
For Each ctl In frm.Controls
' Check to see if control is text box.
If ctl.ControlType = acTextBox Then
' Set control properties.
With ctl
.SetFocus
.Enabled = True
.Height = 400
.SpecialEffect = 0
End With
End If
Next ctl
End Sub
Title: Testing for control type
Post by: Columbia on November 24, 2004, 12:00:02 PM
Amazing what you can find in the online help docs.  Thanks, Hendie, this is just what the doctor ordered...