dbTalk Databases Forums  

Disabling Controls

comp.databases.ms-access comp.databases.ms-access


Discuss Disabling Controls in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Vacuum Sealed
 
Posts: n/a

Default Disabling Controls - 10-08-2011 , 07:26 AM






Hi All

With the exception of one combobox:

Is there a way of disabling all other controlfields on a form without
listing all of them individually.

Also, where would be the best place to seat it...

On_Load()
On_Current()
On_Open()
On_Activate()

I will be able to activate those controls and fields I want based on the
users combobox selection.

TIA
Mick.

Reply With Quote
  #2  
Old   
jbguernsey
 
Posts: n/a

Default Re: Disabling Controls - 10-09-2011 , 02:59 AM






On Oct 8, 1:26*pm, "Vacuum Sealed" <noodn... (AT) gmail (DOT) com> wrote:
Quote:
Hi All

With the exception of one combobox:

Is there a way of disabling all other controlfields on a form without
listing all of them individually.

Also, where would be the best place to seat it...

On_Load()
On_Current()
On_Open()
On_Activate()

I will be able to activate those controls and fields I want based on the
users combobox selection.

TIA
Mick.
I often use this (in the On Current event for the Form). I put
'Edit' (without the quote marks) in each control's Tag option where I
want that control to be locked. I have a coloured lablel (named
lblLocked) which shows the user when the controls are locked.
Clicking on the label unlocks the controls (similar code to the code
below but in the On Click for the label.

I find this gives me more flexibility than just making the whole Form
read-only.

'================================================= ===
Dim ctl as Control

For Each ctl In Me
If ctl.Tag = "Edit" Then ctl.Locked = True
Next
lblLocked.Visible = True
'================================================= ===

HTH

JB

Wales 22 Ireland 10!!!

Reply With Quote
  #3  
Old   
Vacuum Sealed
 
Posts: n/a

Default Re: Disabling Controls - 10-11-2011 , 06:52 AM



Hi JB

Apologies for not responding earlier.

I like your approach, so I modded it slightly by removing the lbl reference
as I only want the field itself to be disabled when focus is on the form
when it opens by any means, although I came up blank as all of my fields and
combos were still active even after placing tags in all.

Here's what I did:

Private Sub Form_Open(Cancel As Integer)
Dim ctl As Control
For Each ctl In Me
If ctl.Tag = "General" Then ctl.Locked = True
If ctl.Tag = "Business" Then ctl.Locked = True
Next
End Sub

I placed this in Form_Activate(), Form_Current(), those areas that are focus
related to the form.

I then made a module with 2 sub routines

1 to activate "General" fields and de-activate "Business" fields, the other
does the opposite:

Sub General_Client()
Dim ctl As Control
Dim myFrm As Form
Set myFrm = Forms!frmmCustomers
For Each ctl In myFrm
If ctl.Tag = "General" Then ctl.Locked = False
If ctl.Tag = "Business" Then ctl.Locked = True
Next
End Sub

Sub Business_Client()
Dim ctl As Control
Dim myFrm As Form
Set myFrm = Forms!frmmCustomers
For Each ctl In myFrm
If ctl.Tag = "General" Then ctl.Locked = True
If ctl.Tag = "Business" Then ctl.Locked = False
Next
End Sub

Should this be a dead end then I may just have to do it the old-fashioned
way and crunch each one for both enabled = true & false.

Thanks again for the assist.
Mick

Reply With Quote
  #4  
Old   
Vacuum Sealed
 
Posts: n/a

Default Re: Disabling Controls - 10-11-2011 , 07:04 AM



Oops.!!

forgot to add this.

I placed this in the After_Update() of my Customer Type combo.

Private Sub cboCustType_AfterUpdate()
If Me.txtCustTypeID = 1 Then
Call modCustomerType.General_Client
Else
Call modCustomerType.Business_Client
End If
End Sub

Cheers
Mick.

Reply With Quote
  #5  
Old   
jbguernsey
 
Posts: n/a

Default Re: Disabling Controls - 10-11-2011 , 11:33 AM



On Oct 11, 1:04*pm, "Vacuum Sealed" <noodn... (AT) gmail (DOT) com> wrote:
Quote:
Oops.!!

First thing ... code needs to be in the On Current and/or On Load
event. Form Open will not work (I believe) since the form's controls
have not been loaded at that point.

Second thing - the Tag needs to be General or Business - no speech
marks in the Tag item.

You wrote that you did this:

Private Sub Form_Open(Cancel As Integer)
Dim ctl As Control
For Each ctl In Me
If ctl.Tag = "General" Then ctl.Locked = True
If ctl.Tag = "Business" Then ctl.Locked = True
Next
End Sub

which seems to suggest you put the code in the Open event for the
form. Doesn't work - see above.

Try the code:

Dim ctl As Control
For Each ctl In Me
If ctl.Tag = "General" Then ctl.Locked = True
If ctl.Tag = "Business" Then ctl.Locked = True
Next

in the on current event.

If it works then you'll probably be OK.


JB
Quote:
forgot to add this.

I placed this in the After_Update() of my Customer Type combo.

Private Sub cboCustType_AfterUpdate()
* * If Me.txtCustTypeID = 1 Then
* * * * * Call modCustomerType.General_Client
* * Else
* * * * Call modCustomerType.Business_Client
* * End If
End Sub

Cheers
Mick.

Reply With Quote
  #6  
Old   
Vacuum Sealed
 
Posts: n/a

Default Re: Disabling Controls - 10-12-2011 , 06:48 PM



Hi JB

Sorry, that doesn't work either.

Thx for your efforts, I will set each one individual.

Thx again.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.