Forum Discussion
ryanbarton324
Apr 26, 2021Copper Contributor
Running VBA code after clicking on a UserForm 'image'
Hello, I am currently trying to write some VBA code that will initialize once I left click on a UserForm image I have uploaded. In my specific situation, I am using a hovering effect for a 'Login...
- Apr 28, 2021
There is a textbox named TextBox1 on top of the Password text box.
So you actually enter the password in TextBox1, and the Password text box remains empty. Hence the message that the login information is incorrect.
HansVogelaar
Apr 26, 2021MVP
Added later: the Image control actually does have a Click event, but it is hidden. See the replies by JonPeltier below.
The Image control does not have a click event. you can use the MouseUp (or MouseDown) event instead, with syntax
Private Sub Image1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
' your code here
End Sub
with the name of your control instead of Image1, of course.
JonPeltier
May 06, 2021MVP
As a matter of fact, you can have a click event for an image control. It appears as a deprecated item in the Object Browser if you show hidden members. You can't add it using the usual dropdown in the code module header, but you can write a sub named "Image1_Click()" (or whatever the image's name is), and it will work as expected.
I don't know why it wasn't working for this user. I'd suggest it was a typo, but I'm the only bad typist in this forum :).
I don't know why it wasn't working for this user. I'd suggest it was a typo, but I'm the only bad typist in this forum :).