Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I change ActiveControl properties using vba Access?

I have created this sub to do some formatting depending on ActiveControl CommandButton

Sub ReFormat(Sender As CommandButton)
    'Me.PictureBox.Picture = Me.Controls(Sender).Picture
    Me.PictureBox.Picture = Sender.Picture
    Me.lbl.Caption = Sender.Caption
    Sender.PictureCaptionArrangement = acRight
    Sender.FontBold = True
    Sender.ForeColor = RGB(45, 48, 60)
End Sub

And called it from :

Private Sub Command0_Click()
    ReFormat (ActiveControl)
End Sub

It throws this error

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

I tried this

Sub ReFormat(Sender As Object)
Sub ReFormat(Sender As Control)

Still the same .

What am I doing wrong ?

>Solution :

The parenthesis makes it read-only. Try:

ReFormat ActiveControl
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading