Using WITH statement and variables

G

Guest

Hi,

I want to create a function to change the fore colour of a specified control
on a specified form, but get an error when trying to use a variable with the
WITH statement:

Form mousemove event calls the function.

Private Sub Text1_MouseMove()
Call Change_Control_Colour("Forms!Form1","Text1")
End Sub

Public Function Change_Control_Colour(strForm, strControl AS String)

With strForm & "!" & strControl
.Forecolor = 255
End With

End Function

Can anyone help? (the code above is an example and may not work!)

Cheers,
Steve.
 
N

Naresh Nichani MVP

Hi:

Try this --
Private Sub Text1_MouseMove()
Call Change_Control_Colour(Text1)
End Sub

Public Function Change_Control_Colour(ctl as Access.Control)

With ctl
.Forecolor = 255
End With
End Function

Regards,

Naresh Nichani
Microsoft Access MVP
 
G

Guest

I have tried it but it doesnt quite work.

When the function is called ctl is Null. There are no errors but the colour
does not change.

Cheers.
Steve.
 
G

Guest

Sorry!

I did work, I wanted the Forecolor of the associated label to show a
different colour, not the textbox itself!

D'Oh!

Thanks for the help (it saves a lot of 'background' coding to highlight the
labels)

Steve.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top