Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

fill in the missing words?

Status
Not open for further replies.

ProgramError

Programmer
Mar 2, 2005
1,027
GB
Hi all,

I need a little help filling in the space of the code below. the code works if the sub is in the forms module using me.form in the line For Each ctrl In me.form But I would like to make this generic to all forms and I cant seem to find the right syntax. Can anyone help?

Code:
  ' reset all background colours to standard
    ChangeCTRLSToWhiteBG (????)

Code:
Public Sub ChangeCTRLSToWhiteBG(FormName As ????)
Dim ctrl As Control
  For Each ctrl In ?????
     If ctrl.ControlType = acTextBox Or ctrl.ControlType = acComboBox Then
      ctrl.BackColor = AcWhite
    End If
  Next
End Sub


Ian Mayor (UK)
Program Error
Always make your words sweet and nice. Because you never know when you may have to eat them.
 
How about:

[tt]
ChangeCTRLSToWhiteBG (Me)



Public Sub ChangeCTRLSToWhiteBG(frm As Form)
Dim ctrl As Object
For Each ctrl In frm.Controls[/tt]
 
thanks remou,


I'm still getting a type mismatch error and it stops on ChangeCTRLSToWhiteBG (me).
I tried me.form as well just in case but same error occurred.

Ian Mayor (UK)
Program Error
Always make your words sweet and nice. Because you never know when you may have to eat them.
 
Oops.

Code:
Public Sub ChangeCTRLSToWhiteBG(frm As Object)
Dim ctrl As Object
  For Each ctrl In frm '.Controls
     If ctrl.ControlType = acTextBox Or ctrl.ControlType = acComboBox Then
      ctrl.BackColor = vbWhite
    End If
  Next
End Sub
 
It worked, although the boxs are black so i will just have to set the acwhite const in the module
thanks remou

Ian Mayor (UK)
Program Error
Always make your words sweet and nice. Because you never know when you may have to eat them.
 
Not acwhite, vbWhite as I mention above.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top