Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hyperlink coding problem

Status
Not open for further replies.

tizwaz

Technical User
Aug 8, 2002
437
GB
I am trying to add code to the close button of my form to send an auto email and at the bottom of the email I want a hyperlink which will open a document. This is what I have but I keep getting error 91 object variable or with block variable not set. Also I would like to add a blank line between the message text and the hyperlink - how do I do this?

Private Sub cmdClose_Click()
Dim strmessage As String
Dim hyppath As Hyperlink
strmessage = Me.txtdetails
hyppath = Me.txtHyperlink
On Error GoTo Err_cmdClose_Click
DoCmd.SendObject , , , "Smith John", , , "New Cleaning Complaint received", strmessage + hyppath, False



DoCmd.Close

Exit_cmdClose_Click:
Exit Sub

Err_cmdClose_Click:
MsgBox Err.Description
Resume Exit_cmdClose_Click

End Sub
 
You would need to use Set with hyppath, as it is defined as an object, however, I do not believe you want an object, just text.

Code:
On Error GoTo Err_cmdClose_Click

strmessage = Me.txtdetails
strmessage = strmessage & " " & Me.txtHyperlink
'Add a blank line
strmessage = strmessage & vbcrlf

DoCmd.SendObject , , , "Smith John", , , "New Cleaning Complaint received", strmessage + hyppath, False

You are likely to need some extra coding if your hyperlink field is Hyperlink type. Hyperlink type is nearly always more trouble than it is worth.


PS It is always wise to mention the line on which your code is failing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top