Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Sep 2002
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hyperlink Trap, and Docmd.Sendobject (97)

    Evening all <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>

    I have a sneaky suspicion this is going to be difficult.. but here goes...


    I have a form set up that displays lists of documents, from various queries. eg.. Docnumber, DocName.
    The Docname is a Hyperlink that opens the relevent word or excel file.
    Currently if the hyperlink is empty nothing happens when you click on it., what i'd like to do firstly.... , is trap this non-event to a click.

    Then, i'd like to email a fixed address, that this Docnumber link didn't work.
    I have set this text, and placed it on a button...

    DoCmd.SendObject acSendNoObject, acFormatTXT, "s.wilders@ge.cokecce.com", , , message, "No text", False

    Which results in this error:

    'Run time error 2046'
    The command or action 'SendObject' isn't available now'
    You may be in a read-only database or an unconverted database from an earlier version of microsoft access'
    The type of object the action applies to isn't currently selected or isn't in the active view
    Use only those commands and macro actions that are currently available for this database.

    Most of the database tables are imported automagically from another database sitting on the system. (I have no idea
    how this works.. it just... does. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>

    Heh, ok.. thats two problems...

    Also the email we use is Lotus Notes, after a trawl through links here, seems to wants some weirdo DLL, VIM thingie.. <img src=/S/crazy.gif border=0 alt=crazy width=15 height=15>

    The whole of the site uses Lotus Notes, so installing a DLL etc is not really a practical option for all the machines, I did a quick
    search for the aforenotmentioned DLL, and it wasn't on my C: Drive.,


    Sooo.. Is this possible, or should i just go and do something less confusing instead ? <img src=/S/brickwall.gif border=0 alt=brickwall width=25 height=15>

    Steve

  2. #2
    New Lounger
    Join Date
    Nov 2001
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hyperlink Trap, and Docmd.Sendobject (97)

    Steve,

    1. Add code to the Click event of the txt box on your form that is bound to your hyperlink field like this :-

    If IsNull(Me!txtFileName) Then
    MsgBox ("Field is empty")
    End If

    Rather than display the message box, your code should call a sub that will send the email.


    2. I have recently had to add functionality to an Access app to enable it to send email. We also use Lotus Notes in our company.

    I unsuccessfully tried to use the Docmd.sendobject method for a number of days. I got various error messages and couldn't get it to work despite having applied all the fixes recommended on the MS Knowledge Base - such as deleting registry entries etc.. Having trawled the web for days on end I finally came across the following excellent solution which is quick and easy to set-up and which works every time.

    Go to the following web page and download the free VBSendMail DLL. It comes with the source code and also some excellent documentation/instructions.

    http://www.freevbcode.com/ShowCode.Asp?ID=109

    You need to copy the DLL onto the client machine and register it. You then add a reference to your Access application. You can then add the following code to your app.

    'Module Level Declaration (WithEvents optional but recommended)
    Private WithEvents poSendMail as vbSendMail.clsSendMail

    Private Sub cmdSend_Click()
    'Assumes you have a form with text boxes named as below

    set poSendMail = new vbSendMail.clsSendMail

    poSendMail.SMTPHost = txtServer.Text
    poSendMail.From = txtFrom.Text
    poSendMail.FromDisplayName = txtFromName.Text
    poSendMail.Recipient = txtTo.Text
    poSendMail.Subject = txtSubject.Text
    poSendMail.Attachment = txtFileName.text 'attached file name
    poSendMail.Message = txtMsg.Text
    poSendMail.Send

    set poSendMail = nothing
    End Sub


    I found that I didn't actually need to use the first line (poSendMail.SMTPHost = txtServer.Text) as this setting is looked up automatically in the latest version of the DLL. I did have to set it when I played with it at home and got it to send mail using my POP3 provider.

    I hope this helps you.

    Dave.

  3. #3
    3 Star Lounger
    Join Date
    Sep 2002
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hyperlink Trap, and Docmd.Sendobject (97)

    Wow,,,, thanks Dave.. i thought it would be complicated. <img src=/S/beep.gif border=0 alt=beep width=15 height=15>

    I will play around with all of that and see what i come up with. !!

    Many thanks for putting me on the right track.

    Steve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •