Re: More code... that i think should work, but doesn't :(
VB Code:
Option Explicit
Private Sub Command1_Click()
Dim ctrl As Control
For Each ctrl In Form1
If typeof ctrl is TextBox Then
ctrl.BackColor = Text1.Text
End If
DoEvents
Next
End Sub
Re: More code... that i think should work, but doesn't :(
Thanks for the speedy reply, i get Syntax Error @
If typeof(ctr) is TextBox Then
and i don't know what to do... sorry.
Re: More code... that i think should work, but doesn't :(
How about his routine that gets the form name passed. You can change the .text = "" to .backcolor = vbred,etc
/=============================================
Public Sub gClearForm(Fname As Form)
On Error GoTo errorhandler
'this routine will be called by each form
'it will clear the text boxes on the form
Dim MyControl As Control
For Each MyControl In Fname.Controls
If TypeOf MyControl Is TextBox Then MyControl.Text = ""
Next MyControl
Exit Sub
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
errorhandler:
Screen.MousePointer = 0
MsgBox "An error occurred: [" & Err.Number & "] " & Err.Description & " - Source: " & Err.Source
End Sub
Re: More code... that i think should work, but doesn't :(
Sorry about that. Remove the ( ) and it should be fine.
My copy/paste skills aren't working right this morning. :wave:
Re: More code... that i think should work, but doesn't :(
DGlienna, your code still failed to work.. sorry to say that.
Other dude who posted routine (forgot your name already :(
Thanks so much, that works well, and is modified to work now :)
Pos Rep for both :)
Re: More code... that i think should work, but doesn't :(
No problem. Don't forget to mark your question as 'resolved'
Re: More code... that i think should work, but doesn't :(
Oops, again. Missed the l on Ctrl.
Thanks.
Re: More code... that i think should work, but doesn't :(
The problem is the For Each statement. For Each ctrl In Form1? Form1 what? Form1.Controls!
VB Code:
Dim ctrl As Control
For Each ctrl In Form1.Controls
If TypeOf ctrl Is TextBox Then
ctrl.BackColor = CLng(Text1.Text) 'Of course Text1.Text must contain a color value
End If
Next
Re: More code... [resolved]
I've never needed that, as Ctrl was declared as a Control, so For Each Control in Forms works.
Re: More code... [resolved]
Thank you Joacim :D
I've just noticed that myself :D
Now i can save two ways of doing this :D Thanks :)