Screen.ActiveControl?

Gasman

Enthusiastic Amateur
Local time
Today, 08:08
Joined
Sep 21, 2011
Messages
16,643
Hi,

I am trying to write a piece of code that I can use in any event, rather than having to change it to suit for each name of the control on the form.

In Foxpro we had the ability to use 'macro substitution', so where I would want to issue a command like 'cb.SetText Me.Size' or 'cb.SetText Me.Ship' I would write the equivalent cb.SetText &ControlName where Control name would contain "Me.Size" or "Me.Ship".

Is there an equivalent method in Access please.?

TIA
 
Not sure what you ask.

Dim ctl As Control
Set ctl = YourControlName

From now you can use for "ctl" all the properties of YourControlName
 
Not sure what you ask.

Dim ctl As Control
Set ctl = YourControlName

From now you can use for "ctl" all the properties of YourControlName

Thanks for the reply.

I've now found the ActiveControl object and have managed it that way.

If I was to use your ctl in it's place (saving typing) how would I write the statement please.?

This is what I have so far.

Code:
Private Sub Size_Enter()
Set cb = New MSForms.DataObject

Me.ActiveControl.SelStart = 0
Me.ActiveControl.SelLength = Len(Me.ActiveControl.Text)

cb.SetText Me.ActiveControl.Text

cb.PutInClipboard

Set cb = Nothing

End Sub
 

Users who are viewing this thread

Back
Top Bottom