Thank you for the reply!
I had already read the article but I feel like my problem is a little different.
If I understand correctly, in your example the button is made transparent after it is clicked (by setting the checkbox to true and making the button transparent in the detail paint event if the checkbox value is true).
In my case I want the button (or rather 2 buttons actually) to be only visible and clickable when the value "Me!files" for that record is not Null or empty.
I changed my code to this:
Code:
Private Sub Detailbereich_Paint()
Me.btnViewFiles.Transparent = Nz(Me!dateien) = ""
Me.btnOpenFiles.Transparent = Nz(Me!dateien) = ""
End Sub
Private Sub btnOpenFiles_Click()
If Nz(Me!dateien) <> "" Then
MsgBox "Executed"
End If
End Sub
Private Sub btnViewFiles_Click()
If Nz(Me!dateien) <> "" Then
MsgBox "Executed"
End If
End Sub
Initially the buttons are now only visible when the corresponding value of me!files is not Null or empty. This is now behaving as it should. Now the msgbox also only pops up when me!files is not Null or empty. This is also behaving as expected now.
However, there is one last issue that I cannot seem to resolve.
When hovering and/or clicking on the right button (btnViewFiles) it can often be seen, even though it should actually be transparent. This does not happen with the left button (btnOpenFiles).
That seems really odd to me, since I used the same code for both buttons so far. I also tried deleting and recreating that second button or to copy/paste the first button that is behaving correctly. The issue remains the same though.
To clarify my problem I attach some screenshots here:
After the form is loaded, both buttons are correctly shown only for the last record (which contains a value for me!files):
View attachment 112574
Now I move the cursor above the area on where the second button would be in the third record and I click. Then that button is suddenly seen (but the msgbox does not pop up):
View attachment 112575
Now I move the cursor further up to the first record. When hovering over the transparent buttons, they are now also suddenly seen:
View attachment 112576
The top right 3 buttons should not be visible in this example. After clicking either of these 3 buttons, they may or may not disappear again. This behavior does not occur for the left button, only for the right one.
As mentioned earlier, I have no other events other than "on click" defined for these buttons.
Do you have any idea what could be the problem here? Thank you