Full Version: Combo Disabled from Option Group code not working.
UtterAccess Forums > Microsoft® Access > Access Forms
leaning
All,
I have a form with a 6-buton option group and then a bunch of combo boxes.
Oget this error :
Run-time error '438'
Object doesn't support this property or method
CODE
Private Sub ogMEPSRole_AfterUpdate()
Me!TrngClassesStatus.Enabled = Not (Me!ogMEPSRole = 5 Or Me!ogMEPSRole = 6)
End Sub

Any ideas what is wrong?
Thanks!
VR/Lost
Bob G
are you trying to set Me!TrngClassesStatus.Enabled = False if those other 2 items are true ??
leaning
Bob,
If the option group output is 1-4, then the combobox is enabled.
If 5 or 6, the combobox is disabled.
HTH!
VR/Lost
Bob G
try this and let me know.
CODE
Private Sub ogMEPSRole_AfterUpdate()
if  Me!ogMEPSRole = 5 or Me!ogMEPSRole = 6 then
Me!TrngClassesStatus.Enabled = false
else
Me!TrngClassesStatus.Enabled = true
End Sub
leaning
Bob,
tried your code and got "Block if without End if" error.
VR/Lost
Bob G
DUOH!!!!
emember it always pays to check my work !!!
Oadded the End If where it belongs. Sorry about that.
CODE
Private Sub ogMEPSRole_AfterUpdate()
if  Me!ogMEPSRole = 5 or Me!ogMEPSRole = 6 then
Me!TrngClassesStatus.Enabled = false
else
Me!TrngClassesStatus.Enabled = true
End If
End Sub
leaning
Bob,
I was hopeful, but it didn't pan out. When I run your code, it gives me the same error:
Run-time error '438'
Object doesn't support this property or method
with the
CODE
Me!TrngClassesStatus.Enabled = true
highlighted.
??
VR/Lost
Bob G
what type of control is this .. TrngClassesStatus
SteveH2508
What type of object is Me!TrngClassesStatus?
Is it a textbox called TrngClassesStatus bound to a field called TrngClassesStatus?
If it is you need to rename the textbox so it is different to the field name e.g. txtTrngClassesStatus
Access gets confused sometimes!
leaning
Steve,
When I create a new form, I just drag the fields onto it. When it does that, Access names the object (text box, combo box, checkbox, etc.) the same name as the field. So, it takes sticktoitiveness to go back through and rename them "txtLName" and "cboAddress". I guess I learned my lesson about the need for that additional effort.
Of course all of my objects had the same name as the fields. Somehwere between renaming them and finding that I had used one of the combobox twice, the problem cleared up and everything is running fine again..<
Do you or anyone know if that is part of any "database checker" or is there VBA to quickly rip through your forms, and say "The name of Text Box blah is the same as the control source for the text box. What would you like to rename the textbox to? Ok, applying that new name to any VBA, formulas, etc. that references it. OK, the new name txtblah has been updated everywhere. Continuing the scan..." rather than going through many text/combo/objects on many forms?
(Thanks for your help, BTW!)
VR/Lost
SteveH2508
Helen Feddema's web site has an add-in which will run through your forms and reports and rename controls.
Bob G
did you end up using your original code or the IF statement ??
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.