Issue with disabling an Option button (1 Viewer)

penfold1992

Registered User.
Local time
Today, 04:52
Joined
Nov 22, 2012
Messages
169
I have a button to clear all fields and also disables some fields
I have a combo box that, on update, fills in all fields and disabled some fields

Seperately, they work... but ive noticed a bug.

If I get myself into this set up:

1) select an option in the combo box to fill in data. fields disabled.
2) select the clear button, all data is removed, fields still disabled.
3) Use a button to enable a small portion of my fields.

4) If I then select an option from the combo box again, fields collect data and disable again like it should.

but..
4) If I click on a option button as if I was changing the data then select an option from the combo box, I get an error... at the option box I changed.
"Run Time Error '2101'
The setting you entered isn't valid for this property"

why does this occur, why does selecting an option button change whether it can be disabled or not?

Also, after I get this error, if I click the clear button again to clear all of my data, and then try to select an option in the combo box, I continue to get the error... like its suddenly not a valid anymore?!
 

MarkK

bit cruncher
Local time
Yesterday, 21:52
Joined
Mar 17, 2004
Messages
8,178
This problem is very specific, but your description is very general. You'll need to post some code or a database or something more to provide enough information for someone to zero in on how to troubleshoot this.
 

penfold1992

Registered User.
Local time
Today, 04:52
Joined
Nov 22, 2012
Messages
169
Apologies, I was supposed to include some code but I forgot in a rush to get out of the office

Code dumps coming up! (I have tried to strip some of them to allow for easier reading, I dont think I have missed any important code in what I have deleted.

Combo Box On Update
Code:
Private Sub WorkPackagecmb_AfterUpdate()
Dim dbs As DAO.Database
Dim rs As DAO.Recordset
Dim SQLstr As String
Set dbs = CurrentDb
Dim MeSub As SubForm
Set MeSub = Me!ClusterSubform
Clear (3)
SQLstr = "SELECT * FROM [Work Groups] " & _
        "INNER JOIN [Cluster] ON [Work Groups].[Work Group]=[Cluster].[Work Group] " & _
        "WHERE [Work Groups].[Work Group]='" & _
         Me.Workgroupcmb.Value & "'"
Set rs = dbs.OpenRecordset(SQLstr)
'Populating Assessment Tab
Me.Summarystr = Nz(rs![Summary], Null)
    'Populating Clusters
MeSub.Form!strRSCMTopic = Nz(rs![RSCM Topic], Null)
MeSub.Form!strRSCMCom = Nz(rs![RSCM Comment], Null)
MeSub.Form!optnRSCMRat = rs![RSCM Rating]
MeSub.Form!optnRSCMScr = rs![RSCM Score]
Call LockClusters
dbs.Close
End Sub

Clear Button
Code:
Private Sub Clearbtn_Click()
Clear (1)
End Sub

Clear Function
Code:
Function Clear(Funct As Byte)
Dim AssessFields As Variant
Dim Var As Variant
Dim MeSub As SubForm
Set MeSub = Me!ClusterSubform
AssessFields = Array(Me.Summarystr, MeSub.Form!optnRSCMRat, MeSub.Form!strRSCMTopic, MeSub.Form!optnRSCMScor, _
        MeSub.Form!strRSCMCom)
If Funct = 1 Or Funct = 3 Then
    For Each Var In AssessFields
        Var.Value = Null
    Next Var
    Call LockClusters
End If
End Function

LockClusters
Code:
Sub LockClusters()
Dim MeSub As SubForm
Dim Cluster As Variant
Dim Var As Variant
Dim Buttons As Variant
Set MeSub = Me!ClusterSubform
Buttons = Array(MeSub.Form!btnRCSM, MeSub.Form!btnRINE)
Cluster = Array(MeSub.Form!RSCMRat1, MeSub.Form!RSCMRat2, MeSub.Form!RSCMRat3, MeSub.Form!strRSCMTopic, _
            MeSub.Form!RSCMScor1, MeSub.Form!RSCMScor2, MeSub.Form!RSCMScor3, MeSub.Form!strRSCMImp)
            
            
Dim x As Integer
x = 0
For Each Var In Cluster
    Var.Enabled = False
Next Var
For Each Var In Buttons
    Var.Value = -1
Next Var
End Sub


Button To enable the section on the subform. (Note this is in the subform's VBA module)
Code:
DisableCluster ("btnRSCM")
Function DisableCluster(btnName As String)
Dim x As Integer
Dim RSCM As Variant
RSCM = Array(Me.RSCMRat1, Me.RSCMRat2, Me.RSCMRat3, Me.strRSCMTopic, Me.RSCMScor1, _
            Me.RSCMScor2, Me.RSCMScor3, Me.RSCMCom)
Select Case btnName
    Case "btnRSCM"
        If Me.strRSCMTopic.Enabled = True Then
            For x = 0 To 7
                RSCM(x).Enabled = False
            Next x
        Else
            For x = 0 To 7
                RSCM(x).Enabled = True
            Next x
            Me.optnRSCMRat = Null
            Me.strRSCMTopic = Null
            Me.optnRSCMScor = Null
            Me.RSCMCom = Null
        End If
End Select
End Function

Lock Clusters
Code:
DisableCluster ("btnRSCM")
Function DisableCluster(btnName As String)
Dim x As Integer
Dim RSCM As Variant
RSCM = Array(Me.RSCMRat1, Me.RSCMRat2, Me.RSCMRat3, Me.strRSCMTopic, Me.RSCMScor1, _
            Me.RSCMScor2, Me.RSCMScor3, Me.RSCMCom)
Select Case btnName
    Case "btnRSCM"
        If Me.strRSCMTopic.Enabled = True Then
            For x = 0 To 7
                RSCM(x).Enabled = False
            Next x
        Else
            For x = 0 To 7
                RSCM(x).Enabled = True
            Next x
            Me.optnRSCMRat = Null
            Me.strRSCMTopic = Null
            Me.optnRSCMScor = Null
            Me.RSCMCom = Null
        End If
End Select
End Function

Hopefully this is enough?
 

DavidAtWork

Registered User.
Local time
Today, 04:52
Joined
Oct 25, 2011
Messages
699
I think you just need to think through clearly what functionality you want to allow when one or more events are dependent on another/other event(s) or controls.
I've usually found it's best to restrict the pathway of events a user can take by hiding/disabling controls until valid decisions/selections have been made.
Having a 'Reset' button is fine, but "Use a button to enable a small portion of my fields" that sounds problematic, can you not enable suitable controls based on selections so far and have those controls enabled or made visible after the relevant selection or option is chosen.
I hope this makes sense, it's a question of design really

David
 

MarkK

bit cruncher
Local time
Yesterday, 21:52
Joined
Mar 17, 2004
Messages
8,178
And the error occurs where?
 

Users who are viewing this thread

Top Bottom