eMail Problem in Access 2007

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KendraAsh
    New Member
    • May 2010
    • 7

    eMail Problem in Access 2007

    I am trying to do the exact same thing; I want to create a button on my form in Access 2007 that, when clicked, opens a new email in Outlook with only the To: field filled in. I tried the code posted by ADezii (replacing [COMPANY_EMAIL] with the name of my field [GROUP_EMAIL_ADD RESS]) but nothing happens when I click the button.

    I am completely new to Access and VB so I'm not sure if there is anything else in the code that I need to change to make it specific to my database. Any help on this would be greatly appreciated as I have been trying to figure this one button out for two weeks now.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32661

    #2
    This post has been moved from Hyperlinks, input masks, and sending email in Access 2007, where any relevant or referenced code may be found.

    Kendra,

    This clearly isn't exactly the same problem, otherwise you wouldn't require further help. If you need help, then you need to create your own thread and not hijack someone else's.

    You may want to specify more clearly exactly what you hope to receive from this question. Expecting someone to check how it fits your database is not likely to get you very far as no-one here knows anything about your database.

    I'm sure if you can make your requirement clear then someone can probably help you.

    Welcome to Bytes!

    Comment

    • KendraAsh
      New Member
      • May 2010
      • 7

      #3
      Sorry I've never tried getting help on a forum before.

      I have created a database in Access 2007 of all the community groups with which my company works. From this database, I created a form to make it a bit easier for others to view and change records. I've noticed that when anyone wants to email one of these groups, they have to copy the email address from the form and paste it into a new message in Outlook.

      I want to make this process easier by creating a button users can click on which will automatically open up a new email window with the To: field pre-populated based on the record the user was viewing.

      Comment

      • Jim Doherty
        Recognized Expert Contributor
        • Aug 2007
        • 897

        #4
        Originally posted by KendraAsh
        Sorry I've never tried getting help on a forum before.

        I have created a database in Access 2007 of all the community groups with which my company works. From this database, I created a form to make it a bit easier for others to view and change records. I've noticed that when anyone wants to email one of these groups, they have to copy the email address from the form and paste it into a new message in Outlook.

        I want to make this process easier by creating a button users can click on which will automatically open up a new email window with the To: field pre-populated based on the record the user was viewing.
        Place this simple command in the on click event of your button. You can then pass the contents of that form textbox to the variable myemail, which in turn is used by the FollowHyperlink command to open an email message. The email address is placed in To: section of the mail window as you require.

        Code:
        Dim myemailTo as string
        myemail=Me!YourTextBoxName
        
        FollowHyperlink myemail

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32661

          #5
          Originally posted by KendraAsh
          KendraAsh: Sorry I've never tried getting help on a forum before.
          That's perfectly fine. I could see you were new and didn't intend to sound heavy.

          I would say though, that you can get so much more from a site such as this (others too of course) with a better understanding of the dos and don'ts of forum etiquette. Our FAQ (FAQ: Posting Guidelines) has some useful guidance that will help you steer through the more obvious pitfalls. Forum sites such as ours can offer so much to people who are trying to learn.

          Comment

          • KendraAsh
            New Member
            • May 2010
            • 7

            #6
            Hi, sorry for the late response.

            I tried the code provided by Jim Doherty but nothing happens when I click the button.

            Comment

            • Jim Doherty
              Recognized Expert Contributor
              • Aug 2007
              • 897

              #7
              Originally posted by KendraAsh
              Hi, sorry for the late response.

              I tried the code provided by Jim Doherty but nothing happens when I click the button.
              Apologies I obviously missed in my pasting one of the main elements. The code below relies on an email address in your textbox, but the command should also have the "mailto:" prefix in order for it to work

              Revised as follows

              Code:
              Dim myemailTo as string 
              myemail="mailto:"& Me!YourTextBoxName 
                
              FollowHyperlink myemail

              Comment

              • KendraAsh
                New Member
                • May 2010
                • 7

                #8
                Still doesn't work. :(

                This may just be something about VBA that I don't understand, but I noticed that your first line has myemailTo but the other two times you use this, there is no To on the end. I don't need it there for this code to work, do I?

                Comment

                • Jim Doherty
                  Recognized Expert Contributor
                  • Aug 2007
                  • 897

                  #9
                  Originally posted by KendraAsh
                  Still doesn't work. :(

                  This may just be something about VBA that I don't understand, but I noticed that your first line has myemailTo but the other two times you use this, there is no To on the end. I don't need it there for this code to work, do I?
                  You are absolutely right that was my typo sorry!!. I will get it right must be having a dense period today. The 'mailto:' is essential the followhyperlink needs that text plus the colon to prefix your email address in order to recognise that it needs to MAIL

                  Code:
                  Dim myemail as string  
                  myemail="mailto:" & Me!YourTextBoxName  
                    
                  FollowHyperlink myemail

                  Comment

                  • KendraAsh
                    New Member
                    • May 2010
                    • 7

                    #10
                    Unfortunately, the button still does nothing when I click on it.

                    Comment

                    • Jim Doherty
                      Recognized Expert Contributor
                      • Aug 2007
                      • 897

                      #11
                      Originally posted by KendraAsh
                      Unfortunately, the button still does nothing when I click on it.
                      How do you mean does nothing? Does it not give you anything?

                      The "mailto: " portion of that command is actually unnecessary in Access 2007 as it should recognise email addresses contained in the textbox

                      try replacing with one space after the colon

                      myemail="mailto : " & Me!YourTextBoxN ame

                      Comment

                      • KendraAsh
                        New Member
                        • May 2010
                        • 7

                        #12
                        I mean I've entered the code in the on click event but when I view the form and try clicking the button it doesn't do anything; it doesn't open a mail window or even give me an error message of any sort.

                        I tried it with the space and I still get nothing :(

                        In theory I understand how this works but every other code I have tried hasn't worked either.

                        Perhaps there is something wrong with the database itself? I mean it is a very simple database for contact and statistical information. I have a column named GROUP_EMAIL_ADD RESS that I have bound to a control in my form. I have called that control MsgAddress. I have tried this code with both names entered and neither returns any results. I have also tried naming the column and the control the same thing and that doesn't work either.

                        It seems like the more I learn about VBA code, the more I don't understand why this isn't working for me. Are there perhaps some troubleshooting methods I could run through to see if the problem is not the code but somewhere else?

                        Comment

                        • Jim Doherty
                          Recognized Expert Contributor
                          • Aug 2007
                          • 897

                          #13
                          Originally posted by KendraAsh
                          I mean I've entered the code in the on click event but when I view the form and try clicking the button it doesn't do anything; it doesn't open a mail window or even give me an error message of any sort.

                          I tried it with the space and I still get nothing :(

                          In theory I understand how this works but every other code I have tried hasn't worked either.

                          Perhaps there is something wrong with the database itself? I mean it is a very simple database for contact and statistical information. I have a column named GROUP_EMAIL_ADD RESS that I have bound to a control in my form. I have called that control MsgAddress. I have tried this code with both names entered and neither returns any results. I have also tried naming the column and the control the same thing and that doesn't work either.

                          It seems like the more I learn about VBA code, the more I don't understand why this isn't working for me. Are there perhaps some troubleshooting methods I could run through to see if the problem is not the code but somewhere else?
                          have you enabled your code on this database?? ie is there a security warning telling you to enable content just beneath the ribbon if so then enable else nothing will work

                          Comment

                          • KendraAsh
                            New Member
                            • May 2010
                            • 7

                            #14
                            I feel so silly I didn't know what that warning was about so just in case I left it alone. Now the code works perfectly, thank you so much :D

                            Comment

                            • Jim Doherty
                              Recognized Expert Contributor
                              • Aug 2007
                              • 897

                              #15
                              Originally posted by KendraAsh
                              I feel so silly I didn't know what that warning was about so just in case I left it alone. Now the code works perfectly, thank you so much :D
                              Thats ok.... I had the distinct impression it would be something really simple so you are up and running now...good

                              Comment

                              Working...