If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Error 438
I have a routine that I use to set various parameters of certain controls on
my form and I manage which control by assigning each control a "Tag" name as follows :- Public Sub util_FormSetup(frm As Form, Opps As String, Stat As Boolean, all As Integer) Dim cntrl As Control On Error GoTo Err_Util_FormSetup For Each cntrl In frm Debug.Print cntrl.Name; " "; cntrl; " "; cntrl.Tag Select Case all Case 0 ' Apply "Stat" to every Control on the Form cntrl.Properties(Opps) = Stat Case 1 ' Apply "Stat" only to a Control If cntrl.Tag = "Lock" Then cntrl.Properties(Opps) = Stat 'where Tag = "Lock" Case 2 ' Apply "Stat" only to a Control If cntrl.Tag = "Find" Then cntrl.Properties(Opps) = Stat 'where Tag = "Find" End Select Next cntrl Exit_Util_FormSetup: Exit Sub With the appropriate parameters being passed to the routine. "Form" = the Form Name, "Opps" = the operation Visible / Locked etc, "Stat" = True / False and "all" is a numeric value that picks out which group of controls I want to work on i.e 0 = All the Controls on the Form, 1 = only the controls with "Tag" set to "Lock" etc My logic being that the operation would only be actioned on a control where the appropiate Tag was set. If a control had it's Tag set to nothing or set to anything other than what was required then the operation should then skip past it and not effect any change. Howeve, wenever I use this routine to "Lock" or "Unlock" a control for editing, the routine seems to run through a few controls OK and the produces an Error Number 438 "object does not support this property or method". I have a sneaky feeling that this could be something to do with the labels that are on the form but if their Tag is Blank the routine should just ignore the label and move on to the next control. This routine used to work fine until recently and whilst I appreciate that I must have done something to affect the change, I do not know what that might be and therefore I can not put it right. Any help appreciated Thanks ray C |
#2
|
|||
|
|||
Error 438
Ray C wrote:
I have a routine that I use to set various parameters of certain controls on my form and I manage which control by assigning each control a "Tag" name as follows :- Public Sub util_FormSetup(frm As Form, Opps As String, Stat As Boolean, all As Integer) Dim cntrl As Control On Error GoTo Err_Util_FormSetup For Each cntrl In frm Debug.Print cntrl.Name; " "; cntrl; " "; cntrl.Tag Select Case all Case 0 ' Apply "Stat" to every Control on the Form cntrl.Properties(Opps) = Stat Case 1 ' Apply "Stat" only to a Control If cntrl.Tag = "Lock" Then cntrl.Properties(Opps) = Stat 'where Tag = "Lock" Case 2 ' Apply "Stat" only to a Control If cntrl.Tag = "Find" Then cntrl.Properties(Opps) = Stat 'where Tag = "Find" End Select Next cntrl Exit_Util_FormSetup: Exit Sub With the appropriate parameters being passed to the routine. "Form" = the Form Name, "Opps" = the operation Visible / Locked etc, "Stat" = True / False and "all" is a numeric value that picks out which group of controls I want to work on i.e 0 = All the Controls on the Form, 1 = only the controls with "Tag" set to "Lock" etc My logic being that the operation would only be actioned on a control where the appropiate Tag was set. If a control had it's Tag set to nothing or set to anything other than what was required then the operation should then skip past it and not effect any change. Howeve, wenever I use this routine to "Lock" or "Unlock" a control for editing, the routine seems to run through a few controls OK and the produces an Error Number 438 "object does not support this property or method". I have a sneaky feeling that this could be something to do with the labels that are on the form but if their Tag is Blank the routine should just ignore the label and move on to the next control. This routine used to work fine until recently and whilst I appreciate that I must have done something to affect the change, I do not know what that might be and therefore I can not put it right. Any help appreciated Thanks ray C I see you have a debug print before entering the loop, that means you know which control it barfs on. Let's say you're looping all controls, then consider that labels, command buttons, and perhaps some other control types, does not have a locked property. You might want to do some check what kind of control it is, which you can do for instance through tests of the following kind Select Case cntrl.ControlType Case acComboBox, acListBox, acTextBox, ... where you can exclude certain types of controls prior to altering certain properties. -- Roy-Vidar |
#3
|
|||
|
|||
Error 438
Hi Roy, thank you for your input. whilst it did not solve my problem it makes
the whole routine much better to filter out the controls that I am not interested in and I did not know how to do that before. It seems that the offending issue was the line Debug.Print cntrl.Name; '" "; cntrl; " "; cntrl.Tag Where it would print the required info until it is asked to print a "Tab" that I have in my Form and that is what was cusing the error message. thanks for you kind help anyway regards RayC "RoyVidar" wrote: Ray C wrote: I have a routine that I use to set various parameters of certain controls on my form and I manage which control by assigning each control a "Tag" name as follows :- Public Sub util_FormSetup(frm As Form, Opps As String, Stat As Boolean, all As Integer) Dim cntrl As Control On Error GoTo Err_Util_FormSetup For Each cntrl In frm Debug.Print cntrl.Name; " "; cntrl; " "; cntrl.Tag Select Case all Case 0 ' Apply "Stat" to every Control on the Form cntrl.Properties(Opps) = Stat Case 1 ' Apply "Stat" only to a Control If cntrl.Tag = "Lock" Then cntrl.Properties(Opps) = Stat 'where Tag = "Lock" Case 2 ' Apply "Stat" only to a Control If cntrl.Tag = "Find" Then cntrl.Properties(Opps) = Stat 'where Tag = "Find" End Select Next cntrl Exit_Util_FormSetup: Exit Sub With the appropriate parameters being passed to the routine. "Form" = the Form Name, "Opps" = the operation Visible / Locked etc, "Stat" = True / False and "all" is a numeric value that picks out which group of controls I want to work on i.e 0 = All the Controls on the Form, 1 = only the controls with "Tag" set to "Lock" etc My logic being that the operation would only be actioned on a control where the appropiate Tag was set. If a control had it's Tag set to nothing or set to anything other than what was required then the operation should then skip past it and not effect any change. Howeve, wenever I use this routine to "Lock" or "Unlock" a control for editing, the routine seems to run through a few controls OK and the produces an Error Number 438 "object does not support this property or method". I have a sneaky feeling that this could be something to do with the labels that are on the form but if their Tag is Blank the routine should just ignore the label and move on to the next control. This routine used to work fine until recently and whilst I appreciate that I must have done something to affect the change, I do not know what that might be and therefore I can not put it right. Any help appreciated Thanks ray C I see you have a debug print before entering the loop, that means you know which control it barfs on. Let's say you're looping all controls, then consider that labels, command buttons, and perhaps some other control types, does not have a locked property. You might want to do some check what kind of control it is, which you can do for instance through tests of the following kind Select Case cntrl.ControlType Case acComboBox, acListBox, acTextBox, ... where you can exclude certain types of controls prior to altering certain properties. -- Roy-Vidar |
Thread Tools | |
Display Modes | |
|
|