I have a main form showing details of a project, with a subform in continuous view, showing details of people who are working on it. One of the fields on that subform is PI_Email_Address.
I have set the Display As Hyperlink property to Always and I assume I now need to set the Hyperlink Address using VBA.
In the source table, the field type is text, rather than hyperlink, because the tables are not local. In fact this database uses several SharePoint lists which are linked as tables. I don’t know whether that complicates things much.
I have done something similar before in another database, although in that case the email field was on a form in single view rather than continuous view. Anyway, using that approach, I came up with the following and inserted it on the Current event of the form that’s being used as a subform
However, there are four records on my first subform of which only one has a completed email address. But the EmailIcon is visible on all four. And when I click it nothing happens anyway.
Would that code work if I attached it to a different event, or maybe even to the parent form? And/or do I need to add some code to the click event of the EmailIcon itself?
Ideally, I would like to be able to just click the email address as it’s displayed and not bother with the EmailIcon at all, but I don’t know if that’s possible.
The fact that the icon is visible on all four records leads me to suspect this is caused by having the form in continuous view. But I’d really rather not have to change that!
Thanks,
Pat.
I have set the Display As Hyperlink property to Always and I assume I now need to set the Hyperlink Address using VBA.
In the source table, the field type is text, rather than hyperlink, because the tables are not local. In fact this database uses several SharePoint lists which are linked as tables. I don’t know whether that complicates things much.
I have done something similar before in another database, although in that case the email field was on a form in single view rather than continuous view. Anyway, using that approach, I came up with the following and inserted it on the Current event of the form that’s being used as a subform
Code:
Private Sub Form_Current()
'EmailIcon is a small image of an envelope inserted on the form
If Not IsNull(Me.PI_Email_Address) Then
Me.EmailIcon.HyperlinkAddress = "MailTo:" & Me. PI_Email_Address
Me.EmailIcon.Visible = True
Else
Me.EmailIcon.Visible = False
End If
End Sub
Would that code work if I attached it to a different event, or maybe even to the parent form? And/or do I need to add some code to the click event of the EmailIcon itself?
Ideally, I would like to be able to just click the email address as it’s displayed and not bother with the EmailIcon at all, but I don’t know if that’s possible.
The fact that the icon is visible on all four records leads me to suspect this is caused by having the form in continuous view. But I’d really rather not have to change that!
Thanks,
Pat.