Hi,
We could use an Attachment control in a form to show the image or icon. And then handle Form_Current event to check the format.

The code below checks the attachment extension, if there is no .jpg or .pdf, the control is invisible.
Private Sub Form_Current()
Attach.Visible = False
For i = 0 To Attach.AttachmentCount - 1
If Right(Attach.OldValue(i), 3) = "jpg" Or Right(Attach.OldValue(i), 3) = "pdf" Then
Attach.Visible = True
End If
Next i
If Attach.Visible = False Then
MsgBox "format not compatible"
End If
End Sub
Using Attachment controls, we could see the picture, but for other files type, it shows as an icon.
So if you want to show other file like pdf, you might use Web Browser control to show the attachment.
But none of them could be changed into other control type like label to display the text "format not compatible", so I would suggest choose other ways to show the alert. For attachment controls,
you may make it invisible or change its displayed type, see
AcDisplayAs Enumeration.
Regards,
Celeste
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to
MSDN Support, feel free to contact MSDNFSF@microsoft.com.