Passing form name

I found this code (EnableFormControls) in the forum to enable/disable 
controls on a form but I'm having trouble setting the variable 'frmAny' and 
passing it to the sub EnableFormControls.  What am I doing wrong?  

Sub EnableFormControls(frmAny As Form, _
                           strControlSkip As String, _
                           Optional tfEnable As Boolean = True)
Dim ctlAny As Control
   On Error GoTo ERROR_Handler
   frmAny(strControlSkip).SetFocus
   For Each ctlAny In frmAny.Controls
      If ctlAny.Name <> strControlSkip Then
         Select Case ctlAny.ControlType
            Case acCheckBox, acComboBox, acCommandButton _
                 , acListBox, acOptionGroup, acSubform _
                 , acTextBox, acToggleButton
            ctlAny.Enabled = tfEnable
         End Select
      End If
   Next ctlAny
   Exit Sub

ERROR_Handler:
   If Err.Number = 2164 Then
      Resume Next
   Else
      MsgBox Err.Number & ": " & Err.Description, , _
      "Error in EnableFormControls"
   End If
End Sub

Private Sub Command1_Click()
Dim frmAny As Form
Dim strControlSkip As String
Dim tfEnable As Boolean


frmAny = Form2
strControlSkip = "Text2"
tfEnable = False

EnableFormControls frmAny, strControlSkip, tfEnable
End Sub

0
Utf
2/16/2010 11:56:01 PM
access.modulesdaovba 1670 articles. 0 followers. Follow

11 Replies
804 Views

Similar Articles

[PageSpeed] 20

"Pastor Del" <PastorDel@discussions.microsoft.com> wrote in message 
news:6C2693D5-769E-493E-807E-9C49648E7156@microsoft.com...
>I found this code (EnableFormControls) in the forum to enable/disable
> controls on a form but I'm having trouble setting the variable 'frmAny' 
> and
> passing it to the sub EnableFormControls.  What am I doing wrong?
>
> Sub EnableFormControls(frmAny As Form, _
>                           strControlSkip As String, _
>                           Optional tfEnable As Boolean = True)
> Dim ctlAny As Control
>   On Error GoTo ERROR_Handler
>   frmAny(strControlSkip).SetFocus
>   For Each ctlAny In frmAny.Controls
>      If ctlAny.Name <> strControlSkip Then
>         Select Case ctlAny.ControlType
>            Case acCheckBox, acComboBox, acCommandButton _
>                 , acListBox, acOptionGroup, acSubform _
>                 , acTextBox, acToggleButton
>            ctlAny.Enabled = tfEnable
>         End Select
>      End If
>   Next ctlAny
>   Exit Sub
>
> ERROR_Handler:
>   If Err.Number = 2164 Then
>      Resume Next
>   Else
>      MsgBox Err.Number & ": " & Err.Description, , _
>      "Error in EnableFormControls"
>   End If
> End Sub
>
> Private Sub Command1_Click()
> Dim frmAny As Form
> Dim strControlSkip As String
> Dim tfEnable As Boolean
>
>
> frmAny = Form2
> strControlSkip = "Text2"
> tfEnable = False
>
> EnableFormControls frmAny, strControlSkip, tfEnable
> End Sub
>

First off, the form must be open for this code to work. Also you need to 
reference the form via the Forms collection, like this:

frmAny = Forms!Form2


0
Stuart
2/17/2010 12:14:54 AM
See if this helps. Instead of passing it as a form, I suggest passing the 
form name as string:

Sub EnableFormControls(strFrmAny As string, _
   strControlSkip As String, _
   Optional tfEnable As Boolean = True)
   
   Dim ctlAny As Control
   On Error GoTo ERROR_Handler

   Forms(strFrmAny).(strControlSkip).SetFocus

   For Each ctlAny In Forms(strFrmAny).Controls
      If ctlAny.Name <> strControlSkip Then
         Select Case ctlAny.ControlType
	    Case acCheckBox, acComboBox, acCommandButton, _
	         acListBox, acOptionGroup, acSubform, _
	         acTextBox, acToggleButton
		 ctlAny.Enabled = tfEnable  
         End Select
      End If
   Next ctlAny

Exit Sub

ERROR_Handler:
   If Err.Number = 2164 Then
      Resume Next
   Else
      MsgBox Err.Number & ": " & Err.Description, , _
      "Error in EnableFormControls"
   End If
End Sub

Private Sub Command1_Click()
   Dim strFrmAny As string
   Dim strControlSkip As String
   Dim tfEnable As Boolean


   strFrmAny = "frmAny"
   strControlSkip = "Text2"
   tfEnable = False

   EnableFormControls strFrmAny, strControlSkip, tfEnable

End Sub


"Pastor Del" wrote:

> I found this code (EnableFormControls) in the forum to enable/disable 
> controls on a form but I'm having trouble setting the variable 'frmAny' and 
> passing it to the sub EnableFormControls.  What am I doing wrong?  
> 
> Sub EnableFormControls(frmAny As Form, _
>                            strControlSkip As String, _
>                            Optional tfEnable As Boolean = True)
> Dim ctlAny As Control
>    On Error GoTo ERROR_Handler
>    frmAny(strControlSkip).SetFocus
>    For Each ctlAny In frmAny.Controls
>       If ctlAny.Name <> strControlSkip Then
>          Select Case ctlAny.ControlType
>             Case acCheckBox, acComboBox, acCommandButton _
>                  , acListBox, acOptionGroup, acSubform _
>                  , acTextBox, acToggleButton
>             ctlAny.Enabled = tfEnable
>          End Select
>       End If
>    Next ctlAny
>    Exit Sub
> 
> ERROR_Handler:
>    If Err.Number = 2164 Then
>       Resume Next
>    Else
>       MsgBox Err.Number & ": " & Err.Description, , _
>       "Error in EnableFormControls"
>    End If
> End Sub
> 
> Private Sub Command1_Click()
> Dim frmAny As Form
> Dim strControlSkip As String
> Dim tfEnable As Boolean
> 
> 
> frmAny = Form2
> strControlSkip = "Text2"
> tfEnable = False
> 
> EnableFormControls frmAny, strControlSkip, tfEnable
> End Sub
> 
0
Utf
2/17/2010 4:33:01 AM
You could also try: -
frmAny = Me

-- 
A nod is as good as a wink to a blind horse.


"Pastor Del" wrote:

> I found this code (EnableFormControls) in the forum to enable/disable 
> controls on a form but I'm having trouble setting the variable 'frmAny' and 
> passing it to the sub EnableFormControls.  What am I doing wrong?  
> 
> Sub EnableFormControls(frmAny As Form, _
>                            strControlSkip As String, _
>                            Optional tfEnable As Boolean = True)
> Dim ctlAny As Control
>    On Error GoTo ERROR_Handler
>    frmAny(strControlSkip).SetFocus
>    For Each ctlAny In frmAny.Controls
>       If ctlAny.Name <> strControlSkip Then
>          Select Case ctlAny.ControlType
>             Case acCheckBox, acComboBox, acCommandButton _
>                  , acListBox, acOptionGroup, acSubform _
>                  , acTextBox, acToggleButton
>             ctlAny.Enabled = tfEnable
>          End Select
>       End If
>    Next ctlAny
>    Exit Sub
> 
> ERROR_Handler:
>    If Err.Number = 2164 Then
>       Resume Next
>    Else
>       MsgBox Err.Number & ": " & Err.Description, , _
>       "Error in EnableFormControls"
>    End If
> End Sub
> 
> Private Sub Command1_Click()
> Dim frmAny As Form
> Dim strControlSkip As String
> Dim tfEnable As Boolean
> 
> 
> frmAny = Form2
> strControlSkip = "Text2"
> tfEnable = False
> 
> EnableFormControls frmAny, strControlSkip, tfEnable
> End Sub
> 
0
Utf
2/17/2010 6:01:02 AM
I tried 'frmAny = Me' without success.  DrGUI suggests that I try passing the 
name as a string.  I'll probably go that way because I know I can pass a 
string, but for the sake of greater understanding I'd like to know why I 
can't pass it as a form.  Any ideas?

"ChrisO" wrote:

> You could also try: -
> frmAny = Me
> 
> -- 
> A nod is as good as a wink to a blind horse.
> 
> 
> "Pastor Del" wrote:
> 
> > I found this code (EnableFormControls) in the forum to enable/disable 
> > controls on a form but I'm having trouble setting the variable 'frmAny' and 
> > passing it to the sub EnableFormControls.  What am I doing wrong?  
> > 
> > Sub EnableFormControls(frmAny As Form, _
> >                            strControlSkip As String, _
> >                            Optional tfEnable As Boolean = True)
> > Dim ctlAny As Control
> >    On Error GoTo ERROR_Handler
> >    frmAny(strControlSkip).SetFocus
> >    For Each ctlAny In frmAny.Controls
> >       If ctlAny.Name <> strControlSkip Then
> >          Select Case ctlAny.ControlType
> >             Case acCheckBox, acComboBox, acCommandButton _
> >                  , acListBox, acOptionGroup, acSubform _
> >                  , acTextBox, acToggleButton
> >             ctlAny.Enabled = tfEnable
> >          End Select
> >       End If
> >    Next ctlAny
> >    Exit Sub
> > 
> > ERROR_Handler:
> >    If Err.Number = 2164 Then
> >       Resume Next
> >    Else
> >       MsgBox Err.Number & ": " & Err.Description, , _
> >       "Error in EnableFormControls"
> >    End If
> > End Sub
> > 
> > Private Sub Command1_Click()
> > Dim frmAny As Form
> > Dim strControlSkip As String
> > Dim tfEnable As Boolean
> > 
> > 
> > frmAny = Form2
> > strControlSkip = "Text2"
> > tfEnable = False
> > 
> > EnableFormControls frmAny, strControlSkip, tfEnable
> > End Sub
> > 
0
Utf
2/17/2010 5:58:02 PM
The form was open and I tried 'frmAny = Forms!Form2' without success.  DrGUI 
suggests that I try passing the name as a string.  I'll probably go that way 
because I know I can pass a string, but for the sake of greater understanding 
I'd like to know why I can't pass it as a form.  Any ideas?

"Stuart McCall" wrote:

> "Pastor Del" <PastorDel@discussions.microsoft.com> wrote in message 
> news:6C2693D5-769E-493E-807E-9C49648E7156@microsoft.com...
> >I found this code (EnableFormControls) in the forum to enable/disable
> > controls on a form but I'm having trouble setting the variable 'frmAny' 
> > and
> > passing it to the sub EnableFormControls.  What am I doing wrong?
> >
> > Sub EnableFormControls(frmAny As Form, _
> >                           strControlSkip As String, _
> >                           Optional tfEnable As Boolean = True)
> > Dim ctlAny As Control
> >   On Error GoTo ERROR_Handler
> >   frmAny(strControlSkip).SetFocus
> >   For Each ctlAny In frmAny.Controls
> >      If ctlAny.Name <> strControlSkip Then
> >         Select Case ctlAny.ControlType
> >            Case acCheckBox, acComboBox, acCommandButton _
> >                 , acListBox, acOptionGroup, acSubform _
> >                 , acTextBox, acToggleButton
> >            ctlAny.Enabled = tfEnable
> >         End Select
> >      End If
> >   Next ctlAny
> >   Exit Sub
> >
> > ERROR_Handler:
> >   If Err.Number = 2164 Then
> >      Resume Next
> >   Else
> >      MsgBox Err.Number & ": " & Err.Description, , _
> >      "Error in EnableFormControls"
> >   End If
> > End Sub
> >
> > Private Sub Command1_Click()
> > Dim frmAny As Form
> > Dim strControlSkip As String
> > Dim tfEnable As Boolean
> >
> >
> > frmAny = Form2
> > strControlSkip = "Text2"
> > tfEnable = False
> >
> > EnableFormControls frmAny, strControlSkip, tfEnable
> > End Sub
> >
> 
> First off, the form must be open for this code to work. Also you need to 
> reference the form via the Forms collection, like this:
> 
> frmAny = Forms!Form2
> 
> 
> .
> 
0
Utf
2/17/2010 5:58:12 PM
Thanks, I'm sure I can pass the string & I'll probably do it this way.  But, 
can you explain why I couldn't pass it as a form, just for a better 
understanding of the beast?

"DrGUI" wrote:

> See if this helps. Instead of passing it as a form, I suggest passing the 
> form name as string:
> 
> Sub EnableFormControls(strFrmAny As string, _
>    strControlSkip As String, _
>    Optional tfEnable As Boolean = True)
>    
>    Dim ctlAny As Control
>    On Error GoTo ERROR_Handler
> 
>    Forms(strFrmAny).(strControlSkip).SetFocus
> 
>    For Each ctlAny In Forms(strFrmAny).Controls
>       If ctlAny.Name <> strControlSkip Then
>          Select Case ctlAny.ControlType
> 	    Case acCheckBox, acComboBox, acCommandButton, _
> 	         acListBox, acOptionGroup, acSubform, _
> 	         acTextBox, acToggleButton
> 		 ctlAny.Enabled = tfEnable  
>          End Select
>       End If
>    Next ctlAny
> 
> Exit Sub
> 
> ERROR_Handler:
>    If Err.Number = 2164 Then
>       Resume Next
>    Else
>       MsgBox Err.Number & ": " & Err.Description, , _
>       "Error in EnableFormControls"
>    End If
> End Sub
> 
> Private Sub Command1_Click()
>    Dim strFrmAny As string
>    Dim strControlSkip As String
>    Dim tfEnable As Boolean
> 
> 
>    strFrmAny = "frmAny"
>    strControlSkip = "Text2"
>    tfEnable = False
> 
>    EnableFormControls strFrmAny, strControlSkip, tfEnable
> 
> End Sub
> 
> 
> "Pastor Del" wrote:
> 
> > I found this code (EnableFormControls) in the forum to enable/disable 
> > controls on a form but I'm having trouble setting the variable 'frmAny' and 
> > passing it to the sub EnableFormControls.  What am I doing wrong?  
> > 
> > Sub EnableFormControls(frmAny As Form, _
> >                            strControlSkip As String, _
> >                            Optional tfEnable As Boolean = True)
> > Dim ctlAny As Control
> >    On Error GoTo ERROR_Handler
> >    frmAny(strControlSkip).SetFocus
> >    For Each ctlAny In frmAny.Controls
> >       If ctlAny.Name <> strControlSkip Then
> >          Select Case ctlAny.ControlType
> >             Case acCheckBox, acComboBox, acCommandButton _
> >                  , acListBox, acOptionGroup, acSubform _
> >                  , acTextBox, acToggleButton
> >             ctlAny.Enabled = tfEnable
> >          End Select
> >       End If
> >    Next ctlAny
> >    Exit Sub
> > 
> > ERROR_Handler:
> >    If Err.Number = 2164 Then
> >       Resume Next
> >    Else
> >       MsgBox Err.Number & ": " & Err.Description, , _
> >       "Error in EnableFormControls"
> >    End If
> > End Sub
> > 
> > Private Sub Command1_Click()
> > Dim frmAny As Form
> > Dim strControlSkip As String
> > Dim tfEnable As Boolean
> > 
> > 
> > frmAny = Form2
> > strControlSkip = "Text2"
> > tfEnable = False
> > 
> > EnableFormControls frmAny, strControlSkip, tfEnable
> > End Sub
> > 
0
Utf
2/17/2010 6:00:01 PM
"Pastor Del" <PastorDel@discussions.microsoft.com> wrote in message 
news:6C39C27D-AD9A-45FF-934E-2CE83F30DF9C@microsoft.com...
> The form was open and I tried 'frmAny = Forms!Form2' without success.

My bad. Apologies. The line should read:

Set frmAny = Forms!Form2

When you're assigning an object, such as a form or report to a variable, you 
need to use the Set keyword.


0
Stuart
2/17/2010 6:23:30 PM
>>I tried 'frmAny = Me' without success.<< is not very helpful in determining 
the problem. There may be other problems which are preventing it from 
working. However: -

Sub EnableFormControls(frmAny As Form, _
                           strControlSkip As String, _
                           Optional tfEnable As Boolean = True)

is expecting a reference (pointer) to be passed to it and Me should refer to 
the Form in which Private Sub Command1_Click() is running. Since Private Sub 
Command1_Click() is running, and doesn’t close the Form, then the Form must 
be open and Me must be valid.

I did not test Sub EnableFormControls at all but it does, as written, 
require a reference to a Form, not its name. If you are trying to use it on a 
sub Form from a parent Form then pass a reference to the sub Form with 
Me.YourSubFormControlNameGoesHere.Form. That also is untested.

More information about the failure is required, please.  

-- 
A nod is as good as a wink to a blind horse.


"Pastor Del" wrote:

> I tried 'frmAny = Me' without success.  DrGUI suggests that I try passing the 
> name as a string.  I'll probably go that way because I know I can pass a 
> string, but for the sake of greater understanding I'd like to know why I 
> can't pass it as a form.  Any ideas?
> 
> "ChrisO" wrote:
> 
> > You could also try: -
> > frmAny = Me
> > 
> > -- 
> > A nod is as good as a wink to a blind horse.
> > 
> > 
> > "Pastor Del" wrote:
> > 
> > > I found this code (EnableFormControls) in the forum to enable/disable 
> > > controls on a form but I'm having trouble setting the variable 'frmAny' and 
> > > passing it to the sub EnableFormControls.  What am I doing wrong?  
> > > 
> > > Sub EnableFormControls(frmAny As Form, _
> > >                            strControlSkip As String, _
> > >                            Optional tfEnable As Boolean = True)
> > > Dim ctlAny As Control
> > >    On Error GoTo ERROR_Handler
> > >    frmAny(strControlSkip).SetFocus
> > >    For Each ctlAny In frmAny.Controls
> > >       If ctlAny.Name <> strControlSkip Then
> > >          Select Case ctlAny.ControlType
> > >             Case acCheckBox, acComboBox, acCommandButton _
> > >                  , acListBox, acOptionGroup, acSubform _
> > >                  , acTextBox, acToggleButton
> > >             ctlAny.Enabled = tfEnable
> > >          End Select
> > >       End If
> > >    Next ctlAny
> > >    Exit Sub
> > > 
> > > ERROR_Handler:
> > >    If Err.Number = 2164 Then
> > >       Resume Next
> > >    Else
> > >       MsgBox Err.Number & ": " & Err.Description, , _
> > >       "Error in EnableFormControls"
> > >    End If
> > > End Sub
> > > 
> > > Private Sub Command1_Click()
> > > Dim frmAny As Form
> > > Dim strControlSkip As String
> > > Dim tfEnable As Boolean
> > > 
> > > 
> > > frmAny = Form2
> > > strControlSkip = "Text2"
> > > tfEnable = False
> > > 
> > > EnableFormControls frmAny, strControlSkip, tfEnable
> > > End Sub
> > > 
0
Utf
2/17/2010 6:53:02 PM
Stuart pointed out my problem.  When you're assigning an object, such as a 
form or report to a variable, you need to use the Set keyword.  The code I 
initially posted works great when the Set keyword in used.

Thanks for you time and attention


"ChrisO" wrote:

> >>I tried 'frmAny = Me' without success.<< is not very helpful in determining 
> the problem. There may be other problems which are preventing it from 
> working. However: -
> 
> Sub EnableFormControls(frmAny As Form, _
>                            strControlSkip As String, _
>                            Optional tfEnable As Boolean = True)
> 
> is expecting a reference (pointer) to be passed to it and Me should refer to 
> the Form in which Private Sub Command1_Click() is running. Since Private Sub 
> Command1_Click() is running, and doesn’t close the Form, then the Form must 
> be open and Me must be valid.
> 
> I did not test Sub EnableFormControls at all but it does, as written, 
> require a reference to a Form, not its name. If you are trying to use it on a 
> sub Form from a parent Form then pass a reference to the sub Form with 
> Me.YourSubFormControlNameGoesHere.Form. That also is untested.
> 
> More information about the failure is required, please.  
> 
> -- 
> A nod is as good as a wink to a blind horse.
> 
> 
> "Pastor Del" wrote:
> 
> > I tried 'frmAny = Me' without success.  DrGUI suggests that I try passing the 
> > name as a string.  I'll probably go that way because I know I can pass a 
> > string, but for the sake of greater understanding I'd like to know why I 
> > can't pass it as a form.  Any ideas?
> > 
> > "ChrisO" wrote:
> > 
> > > You could also try: -
> > > frmAny = Me
> > > 
> > > -- 
> > > A nod is as good as a wink to a blind horse.
> > > 
> > > 
> > > "Pastor Del" wrote:
> > > 
> > > > I found this code (EnableFormControls) in the forum to enable/disable 
> > > > controls on a form but I'm having trouble setting the variable 'frmAny' and 
> > > > passing it to the sub EnableFormControls.  What am I doing wrong?  
> > > > 
> > > > Sub EnableFormControls(frmAny As Form, _
> > > >                            strControlSkip As String, _
> > > >                            Optional tfEnable As Boolean = True)
> > > > Dim ctlAny As Control
> > > >    On Error GoTo ERROR_Handler
> > > >    frmAny(strControlSkip).SetFocus
> > > >    For Each ctlAny In frmAny.Controls
> > > >       If ctlAny.Name <> strControlSkip Then
> > > >          Select Case ctlAny.ControlType
> > > >             Case acCheckBox, acComboBox, acCommandButton _
> > > >                  , acListBox, acOptionGroup, acSubform _
> > > >                  , acTextBox, acToggleButton
> > > >             ctlAny.Enabled = tfEnable
> > > >          End Select
> > > >       End If
> > > >    Next ctlAny
> > > >    Exit Sub
> > > > 
> > > > ERROR_Handler:
> > > >    If Err.Number = 2164 Then
> > > >       Resume Next
> > > >    Else
> > > >       MsgBox Err.Number & ": " & Err.Description, , _
> > > >       "Error in EnableFormControls"
> > > >    End If
> > > > End Sub
> > > > 
> > > > Private Sub Command1_Click()
> > > > Dim frmAny As Form
> > > > Dim strControlSkip As String
> > > > Dim tfEnable As Boolean
> > > > 
> > > > 
> > > > frmAny = Form2
> > > > strControlSkip = "Text2"
> > > > tfEnable = False
> > > > 
> > > > EnableFormControls frmAny, strControlSkip, tfEnable
> > > > End Sub
> > > > 
0
Utf
2/17/2010 7:25:01 PM
Thanks, it works great with the Set keyword.  I'm self-taught and had not 
come across this kind of situation before.  Thanks again.

"Stuart McCall" wrote:

> "Pastor Del" <PastorDel@discussions.microsoft.com> wrote in message 
> news:6C39C27D-AD9A-45FF-934E-2CE83F30DF9C@microsoft.com...
> > The form was open and I tried 'frmAny = Forms!Form2' without success.
> 
> My bad. Apologies. The line should read:
> 
> Set frmAny = Forms!Form2
> 
> When you're assigning an object, such as a form or report to a variable, you 
> need to use the Set keyword.
> 
> 
> .
> 
0
Utf
2/17/2010 7:27:01 PM
Yes, Stuart is correct and I should have tested the code.

As a matter of interest: -

Private Sub Command1_Click()
    Dim frmAny As Form
    Dim strControlSkip As String
    Dim tfEnable As Boolean
    
    Set frmAny = Me
    strControlSkip = "Text2"
    tfEnable = False

    EnableFormControls frmAny, strControlSkip, tfEnable
    
End Sub

can be reduced to: -

Private Sub Command1_Click()

    EnableFormControls Me, "Text2", False
    
End Sub

which removes the problem.

-- 
A nod is as good as a wink to a blind horse.


"Pastor Del" wrote:

> Stuart pointed out my problem.  When you're assigning an object, such as a 
> form or report to a variable, you need to use the Set keyword.  The code I 
> initially posted works great when the Set keyword in used.
> 
> Thanks for you time and attention
> 
> 
> "ChrisO" wrote:
> 
> > >>I tried 'frmAny = Me' without success.<< is not very helpful in determining 
> > the problem. There may be other problems which are preventing it from 
> > working. However: -
> > 
> > Sub EnableFormControls(frmAny As Form, _
> >                            strControlSkip As String, _
> >                            Optional tfEnable As Boolean = True)
> > 
> > is expecting a reference (pointer) to be passed to it and Me should refer to 
> > the Form in which Private Sub Command1_Click() is running. Since Private Sub 
> > Command1_Click() is running, and doesn’t close the Form, then the Form must 
> > be open and Me must be valid.
> > 
> > I did not test Sub EnableFormControls at all but it does, as written, 
> > require a reference to a Form, not its name. If you are trying to use it on a 
> > sub Form from a parent Form then pass a reference to the sub Form with 
> > Me.YourSubFormControlNameGoesHere.Form. That also is untested.
> > 
> > More information about the failure is required, please.  
> > 
> > -- 
> > A nod is as good as a wink to a blind horse.
> > 
> > 
> > "Pastor Del" wrote:
> > 
> > > I tried 'frmAny = Me' without success.  DrGUI suggests that I try passing the 
> > > name as a string.  I'll probably go that way because I know I can pass a 
> > > string, but for the sake of greater understanding I'd like to know why I 
> > > can't pass it as a form.  Any ideas?
> > > 
> > > "ChrisO" wrote:
> > > 
> > > > You could also try: -
> > > > frmAny = Me
> > > > 
> > > > -- 
> > > > A nod is as good as a wink to a blind horse.
> > > > 
> > > > 
> > > > "Pastor Del" wrote:
> > > > 
> > > > > I found this code (EnableFormControls) in the forum to enable/disable 
> > > > > controls on a form but I'm having trouble setting the variable 'frmAny' and 
> > > > > passing it to the sub EnableFormControls.  What am I doing wrong?  
> > > > > 
> > > > > Sub EnableFormControls(frmAny As Form, _
> > > > >                            strControlSkip As String, _
> > > > >                            Optional tfEnable As Boolean = True)
> > > > > Dim ctlAny As Control
> > > > >    On Error GoTo ERROR_Handler
> > > > >    frmAny(strControlSkip).SetFocus
> > > > >    For Each ctlAny In frmAny.Controls
> > > > >       If ctlAny.Name <> strControlSkip Then
> > > > >          Select Case ctlAny.ControlType
> > > > >             Case acCheckBox, acComboBox, acCommandButton _
> > > > >                  , acListBox, acOptionGroup, acSubform _
> > > > >                  , acTextBox, acToggleButton
> > > > >             ctlAny.Enabled = tfEnable
> > > > >          End Select
> > > > >       End If
> > > > >    Next ctlAny
> > > > >    Exit Sub
> > > > > 
> > > > > ERROR_Handler:
> > > > >    If Err.Number = 2164 Then
> > > > >       Resume Next
> > > > >    Else
> > > > >       MsgBox Err.Number & ": " & Err.Description, , _
> > > > >       "Error in EnableFormControls"
> > > > >    End If
> > > > > End Sub
> > > > > 
> > > > > Private Sub Command1_Click()
> > > > > Dim frmAny As Form
> > > > > Dim strControlSkip As String
> > > > > Dim tfEnable As Boolean
> > > > > 
> > > > > 
> > > > > frmAny = Form2
> > > > > strControlSkip = "Text2"
> > > > > tfEnable = False
> > > > > 
> > > > > EnableFormControls frmAny, strControlSkip, tfEnable
> > > > > End Sub
> > > > > 
0
Utf
2/17/2010 9:00:01 PM
Reply:

Similar Artilces:

Multiple name appearances
Have a list of 1000 names trying to sort by appearances >5. Not sure if Lookup or Hlookup? Pat318 wrote: > Have a list of 1000 names trying to sort by appearances >5. > Not sure if Lookup or Hlookup? If your list is in A1:A1000, put this in B1:B1000 and sort by column B: =COUNTIF($A$1:$A$1000,A1) ...

How to force special layout of File-as, Full Name and Company
When I enter a new business contact, "Johnny Rockets" for example, I want the Full Name, Company and File As to all show "Johnny Rockets" and not "Rockets, Johnny." Is there a way to cause that to happen without having to go back and adjust the items? Outlook 2007. vista. You can control it for new contacts - Tools, Options, Contact Options to set the file as format and the default name order. See http://www.slipstick.com/Tutorials/contacts/contacts.htm -- Diane Poremsky [MVP - Outlook] Outlook Tips: http://www.outlook-tips.net/ Outlook &...

Range Names
I need to figure out how to automatically assign dynamic range names to each "Saturday to Friday" in a list of monthly day numbers and associated day names for an entire year. A B 1 Sat 2 Sun 3 Mon 4 Tue 5........etc. I don't know where to start. Thanks, Wes Hi Wes, Depending on what you wish to do, XL's built in WeekNum function may assist. --- Regards, Norman "Wes" <additude@texstapes.com> wrote in message news:uV1CDQweFHA.3836@tk2msftngp13.phx.gbl... >I need to figure out how to automatically assign dynamic range name...

Master/content pages: prob with passing a control to JS
Hi, my code: .... <script type="text/javascript"> var myfilter = myJSfunction(document.myform.ListBox1); </script> </form> When compiling the web page, because of the master/content, the Listbox1 control gets a different name/id apparantly. So how can I pass my listbox on as an argument of my JS procedure? thx for helping, J "Jokke" <Jokke007007@hotmail.com> wrote in message news:7839C9C3-037F-4550-B5BC-E6BA75D93A99@microsoft.com... > When compiling the web page, because of the master/content, the L...

Lookup Function in user form
I have a combo box (cboitem1) and a text box (txtprice1). I am using the code below to have txtprice1 fill with the corresponding price the worksheet: Private Sub Cboitem1_Change() If cboItem1 <> "" Then txtprice1.Value = Excel.WorksheetFunction.VLookup(cboItem1.Value, Sheets("Pizzas").Range("A1:B65536"), 2, False) End If End Sub It works perfectly when you enter an existing value in cboitem1. However if 'the user' accidently types a letter that is not the first letter of one of the existing items VB debugging pops up with error &qu...

Name change due to marriage...
I have a user who recently got married and would like to have her new married name for her emails, but also wants external users to be able to send emails to her old address until she has adequate time to inform everyone. Her new email would be something like lastname-newname, firstname instead of lastname, firstname. Should I create a new account with her new name and forward all her emails from the old account to the new one and can I copy her current pst into the new one? THanks for everyone's help. No. Just highlight her account in ADUC, and choose re-name. Make the neede...

Which Controls to Build a Parent/Child Web Form
Hi there, I'm quite new to asp.net, but know exactly how to do this using classic ASP, but would like some pointers for aspnet2. I've got data being returned from an SP which looks like this: HeaderItem ChildItem A A1 A A2 A A3 B B1 etc I want to display the data like this A - This is the header record A1 A2 A3 B - Header 2 B1 etc. In classic ASP I'd write out my header row html when HeaderItem changes value and then write the Child Rows. As I've on...

addressing envelope from data input form
I don't know where to start to try this. I have the following fields that make up the entire address: Fname Lname Fname2 Lname 2 Address City, State Zip Is there any way to "push a button" on a form and have it print an envelope for that record? Thanks in advance for any help. -- Posted via a free Usenet account from http://www.teranews.com Have you thought of using an MS template as a starting point? http://office.microsoft.com/en-us/templates/CT101172481033.aspx Dave Eliot wrote: >I don't know where to start to try this. > >I have the following fields ...

Viewing xml created in .Net in a ASP form VB6
I have been trying to create an xml document in VB.Net for displaying on an existing page written in ASP. im having a type mismatch error in my code. When i view my XML i have the following included in the <binary> node. <Binary xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="bin.base64">DATA HERE </Binary My issue is how do i set the datatype of the the node using dotnet so that i can replicate the same node structure and use my existing ASP page. thanks in advance Colin Graham ...

Faulting application name: iexplore.exe In Windows 2008 Server R2
I am not certain why I keep getting this exception message. In fact I get a pop up most each time I try to access or connect using IE. Did a bit of searching, and have not found a good fix for this yet. I am running a Windows Server 2008 64bit machine. I tried blaming it on IE add-ons, but now I am running in NO-ADDON mode with no add-ons but the problem persists.I would appreciate it if someone helped with with a fix for this on my server. ERRORS TYPES SO FAR ============================================= Faulting application name: iexplore.exe, version: 8.0.7600.16385, tim...

Creating a form or template
We scanned in an image of a post it note that has graphics on it. It is a jpg file. Can we somehow make this jpg file a form or template in Outlook? Ideally, we want to pull up a form that looks like the image of a post it note with the graphics in tact and be able to compose a message on the email post it note. How do you accomplish this? Thanks! ...

Adding BMPs to a form
I use Access 2003. I have a table set up with a field for pictures, this table sits behind a form to add BMPs, which display on the form and print on reports. In the past, when I have had to reinstall Access for any reason, the pictures instead of displaying fully in the form, only show as thumbnails with the file name. I have in the past resoved this by removing Microsoft Picture manager from MS Office. I don't know how I figured that out or why it works but it does. However, I had to reinstall Office yesterday, removed MS Pictrue Manager as usual and it's NOT working ...

Removing gray shading in protected forms (drop down box)
Hello- I am creating some contract templates for my company's sales force using Word 2003. I am using the forms toolbar to insert checkboxes and drop down boxes from which to select deliverable specifications. The problem is that when a user selects an option from the drop down box, the gray shading remains. I know the sales teams HATE the gray shading because they don't think it looks very good when sending to customers. Is there a way to disable the shading when an option is selected? Thanks. You can remove form field shading altogether using the corresponding b...

Combo values from query based on form fields
I am setting the values for a combo box in a form(s) via a query that 'filters' the results with criteria based upon the values of other fields on the form. The combo is a field that is bound. However, this is giving all kinds of problems ranging from Access completely crashing to being asked for the parameter values of those criteria fields when closing the form. I have tried making the combo an unbound field and then setting the value of the bound field to that unbound field after update, but that still leads to the same issues. How can I do this? As example - I have a form w...

Adding User Name to footer
I have spreadsheets that go out to a number of users, and they make various changes and print out for themselves. The problems is that no-one knows which version to pick up from a central printer. Can I add the user name to the footer. I also have the path and file in the same area. I would like to end up with : User Name printed 'path/file' on 'date' ...

Excel 2003 - VBA
With code in Module 6, I created a button on a sheet as follows: ActiveSheet.Buttons.Add(1245, 16, 80, 16).Select Selection.Caption = "AutoFocus On" Selection.Name = "AutoFocusBut" Selection.OnAction = "FocusOn" Focus = True I placed the sub "FocusOn" also in Module 6. Public Sub FocusOn() If Focus = True Then .... .... When the button is depressed I get the message: "Ambigous name detected: FocusOn". What am I missing. Craig My bet is you have two 'things' named FocusOn. Two subs or a sub and a variable...

Name range within a name range
In Excel is it possible to create a name range that contains multiple name ranges. As an example, I have created several name ranges with one cell reference, such as Sales(A2), COS(A5), ADM(A7), SELLING(A8), MRKT(A9). I would like to create a name range that I could include the all the name ranges and call it GROSS_PROFIT. If later I add another range I would like to be able to just add the range name to GROSS_PROFIT, such as R&D. Also the reason I chose to use named ranges is my cell references can change from month to month, I find it easier to create formulas using name refer...

ActiveX vs Forms
Hello- I am trying to embed some option buttons on a worksheet. I want to have two sets of buttons which are mutually exclusive, say A-D and then 1-3. I want to start with 1-3 hidden and if the user chooses option D from the first set then 1-3 will be revealed. I did this fine with the activex option buttons and VBA, however, it is not recognizing A-D and 1-3 as separate groups. Therefore, as soon as the user select 1,2 or 3, it will uncheck D and therefore rehide the remaining numbered boxes. I grouped and named each set of buttons together, but that did not work. If I try to use a group...

Refresh Results In A Second Subform In A Form
Hi, This could be a tricky one. What I've done is created a Form named ACCOUNTS SELECT which has a control being a Comb Box named 'PICK RESNAME' and an embedded subform which returns all the records according to the particular data from the 'PICK RESNAME' Combo Box. Thats all fine and well ! But what I need is to pick specific records and to store them in a let's say temporary Table which I will print out via a Report. For this temporary table, I have created in the Form ACCOUNTS SELECT another Subform which I hoped will view all the selections I have made...

user name and password not being retained in WindowsMail
I have Vista 32bit sp2, IE8 and WindowsMail. I had this problem on my XP/Outlook Express machine and found an answer, but can't find one for WindowsMail. Please note that I have had this set-up for several months and never incurred this problem. Even earlier today everything was working fine. It looks as if I can send messages, but when I click on send/receive button to receive messages I get a screen asking for my username and password. I have it set to remember in 'tools' 'accounts', but it isn't remembering it. Does anyone have a suggestion on how...

Obtain Sub-Folder Names with VBA?
Is it possible to obtain the names of all Sub-Folders for a specific parent Folder? Just 2 levels (1 Parent Folder) and several children folders. We need the names of the sub-folders, not the names of the files in the sub-folders. Thanks for your help. Brad Lookup the Dir Function in the help file, specifically at the example it illustrates exactly how to get a directory listing. You'll see it isn't hard! -- Hope this helps, Daniel Pineault http://www.cardaconsultants.com/ For Access Tips and Examples: http://www.devhut.net Please rate this post using the...

Named Properties Error (Event ID: 9667)
Having problems with good old Event 9667. Thats the problem where Exchange 2003 stop accepting some emails when it hits the 16k soft limit on Named Properties. I've seen the KB article regarding adjusting the size of the named properties cache (if i can call it a cache) up to 32k but, as others have pointed out, that just delays the problem. I would like to know if anyone knows of any good ways to filter headers such that they are reduced to just the standard headers necessary for email delivery? Thanks, K ...

Continuous Form, Window Top Record Ordinal
On continuous view forms, there should be a form property that has the recordset ordinal of the top-most record currently displayed in the form’s window. For example, if a recordset contains 100 records and the CurrentRecord is 5 and the user scrolls down until the CurrentRecord disappears off the top of the screen, what is the recordset ordinal for the record that is now at the top of the window? Left clicking on the scrollbar slider will display “Record: x of y”, but there should be a property that contains the value of x for code purposes. Perhaps call it “WindowTopRecord...

Moving Exchange DB's to a new server (different name)
In a DR test, we moved SG's to a new server, different server name, same SG and MS name. MS mounts, can not connect to mailbox. Delete mailbox, create a new one, we can then connect. Delete this mailbox, reconnect to the original, and now we can connect. How can we accomplish this in bulk? In other words, after doing a system state restore of AD, then a system state of Exchange, restored MS file, mounted, etc. We were unable to connect to these mailboxes. I am assuming this is related to GUID's. Any thoughts? Users in AD specify a server by name. When you say that you move mailbo...

e2k3 sp2: Unknown user name or bad password error
We have an exchange cluster with two nodes that runs exchange 2003 SP2 on windows 2003 Sp1 ent. For security reasons recently I had to change the password for the account under which I installed exchange - the account is exchservice. Since then I get few of the following messages in the security log on the server - any idea how can I stop this? Event Type: Failure Audit Event Source: Security Event Category: Logon/Logoff Event ID: 529 Date: 09/10/2006 Time: 10:30:00 User: NT AUTHORITY\SYSTEM Computer: EMILYA Description: Logon Failure: Reason: Unknown user name or bad password Us...