473,387 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Enable controls on a tabcontrol

Hi developers,

i've a problem with my tabcontrol.
Before i open my form with a tabcontrol with 3 tabs
(Frm_Files|Frm_Lines|Frm_Guarantee) all the controls on al the tabs
must be enabled. With the next code only the controls on the active
form are enabled.

For Each ctl In Me.Controls
Select Case ctl.ControlType
' Ignore a few that won't be changed
Case acLabel, acPageBreak, acPage, acCommandButton, acTabCtl,
acOptionGroup
Debug.Print ctl.Name & " ignored"
Case Else
Debug.Print ctl.Name & " processed"
ctl.Enabled = False
End Select
Next

How can i enable the controls on the tabs (subforms)?
Nov 13 '05 #1
1 4409
To lock the subforms as well, the code needs to call itself recursively when
it finds a control of type acSubform.

The function below does that.
It takes 2 parameters:
- a reference to the to be locked or unlocked;
- True to lock it, or False to unlock it.

Any further parameters you pass are understood to be the names of controls
that are NOT to be locked/unlocked. For example, if you there was one
subform you did not want to lock, you could pass its name and it would not
be changed. (Unbound controls are not locked/unblocked in any case. We tend
to use these for filtering the form, and we want the user to be able to do
that even when the form is "locked".)
-----------------code starts-------------------------------
Public Function LockBoundControls(frm As Form, bLock As Boolean, ParamArray
avarExceptionList())
On Error GoTo Err_Handler
'Purpose: Lock the bound controls and prevent deletes on the form any
its subforms.
'Arguments frm = the form to be locked
' bLock = Trur to lock, False to unlock.
' avarExceptionList: Names of the controls NOT to lock
(variant array of strings).
'Usage: Call LockBoundControls(Me, True)
Dim ctl As Control 'Each control on the form
Dim lngI As Long 'Loop controller.
Dim bSkip As Boolean

'Save any edits.
If frm.Dirty Then
frm.Dirty = False
End If
'Block deletions.
frm.AllowDeletions = Not bLock

For Each ctl In frm.Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox, acListBox, acOptionGroup, acCheckBox,
acOptionButton, acToggleButton
'Lock/unlock these controls if bound to fields.
bSkip = False
For lngI = LBound(avarExceptionList) To
UBound(avarExceptionList)
If avarExceptionList(lngI) = ctl.Name Then
bSkip = True
Exit For
End If
Next
If Not bSkip Then
If HasProperty(ctl, "ControlSource") Then
If Len(ctl.ControlSource) > 0& And Not ctl.ControlSource
Like "=*" Then
If ctl.Locked <> bLock Then
ctl.Locked = bLock
End If
End If
End If
End If

Case acSubform
'Recursive call to handle all subforms.
bSkip = False
For lngI = LBound(avarExceptionList) To
UBound(avarExceptionList)
If avarExceptionList(lngI) = ctl.Name Then
bSkip = True
Exit For
End If
Next
If Not bSkip Then
If Len(Nz(ctl.SourceObject, vbNullString)) > 0& Then
ctl.Form.AllowDeletions = Not bLock
ctl.Form.AllowAdditions = Not bLock
Call LockBoundControls(ctl.Form, bLock)
End If
End If

Case acLabel, acLine, acRectangle, acCommandButton, acTabCtl,
acPage, acPageBreak, acImage, acObjectFrame
'Do nothing

Case Else
'Includes acBoundObjectFrame, acCustomControl
Debug.Print ctl.Name & " not handled in LockBoundControls() at "
& Now()
End Select
Next

Exit_Handler:
Set ctl = Nothing
Exit Function

Err_Handler:
MsgBox "Error " & Err.Number & " - " & Err.Description,
"LockBoundControls"
Resume Exit_Handler
End Function

Public Function HasProperty(obj As Object, strPropName As String) As Boolean
'Purpose: Return true if the object has the property.
Dim vardummy As Variant

On Error Resume Next
vardummy = obj.Properties(strPropName)
HasProperty = (Err.Number = 0)
End Function

-----------------code starts-------------------------------
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"@ndy" <an*******@hotmail.com> wrote in message
news:6c**************************@posting.google.c om...
Hi developers,

i've a problem with my tabcontrol.
Before i open my form with a tabcontrol with 3 tabs
(Frm_Files|Frm_Lines|Frm_Guarantee) all the controls on al the tabs
must be enabled. With the next code only the controls on the active
form are enabled.

For Each ctl In Me.Controls
Select Case ctl.ControlType
' Ignore a few that won't be changed
Case acLabel, acPageBreak, acPage, acCommandButton, acTabCtl,
acOptionGroup
Debug.Print ctl.Name & " ignored"
Case Else
Debug.Print ctl.Name & " processed"
ctl.Enabled = False
End Select
Next

How can i enable the controls on the tabs (subforms)?

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: VJ | last post by:
I am looking to have 2 Tab Controls on a Windows Forms.. One with Tabs on Top and another with Tabs on the side... I want them both to occupy the entire area of the form, but I need the Tab...
7
by: Andrew McKendrick | last post by:
Hi, I've noticed a bug in VB.NET (latest .NET Framework)... - I have a TabControl on a form with several tabs. - Each tab contains text boxes that are bound to fields in a data source...
5
by: scorpion53061 | last post by:
I am trying to be able to share a groupbox and its related controls among all of my tab pages. This does not error but the controls do not appear either. Thank you for your help!! ...
7
by: Phil | last post by:
on my form I have a checkbox and a tab control when the checkbox is true I wish to enable the controls on a single page of the tab control, is this possible or do I need to enable each control on...
10
by: Michael | last post by:
Hi Everyone. I have been designing a form with about 100 or so controls and today I pasted some code from another test project into this one and then all the controls on the form disapeared from...
0
by: veerleverbr | last post by:
Hi, I want to create an asp.net page with a tabpage. On the tabpage I want to use the WebDateChooser and WebDataInput controls of Infragistics. These 2 controls use a mask to enter a date and...
2
by: RichG | last post by:
With the help of Cor Ligthert in a pryor post I was able to make this sub: Public Sub disableControls(ByVal frm As Form) 'this is to create a read only form that has active buttons Dim x As...
7
by: davidpryce123 | last post by:
Dear Windows Form Designers I am developing an application that uses a TabControl with several Tabpages. On the different Tabpages I wish to allow users to have the access to the same...
5
by: Paul Hemans | last post by:
Hi, I am using VS2005. I have a form with a tabControl on it. Suddenly I can no longer see any of my controls, on any of the pages, or even the tabControl itself. They still exist because the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.