Send Mail to Multiple Recipients Form Datasheet View

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • HyBry
    New Member
    • Sep 2007
    • 40

    Send Mail to Multiple Recipients Form Datasheet View

    I have send mail button assigned to datasheet in subform. Works fine if I want to send mail to one person, but I want it to work if I have multiple selection as well.
    code I have now is
    Code:
    FollowHyperlink "mailto:" & Form!list_1_subform3![e-mail]
    Last edited by HyBry; Nov 13 '07, 01:38 PM. Reason: was incomplete
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    You'll need some code to do this.
    The effect of a multiple selection can be seen working in:
    http://www.geocities.c om/nico5038/xSample-Listbox-Datasheet-Up-Down2000.zip

    Use this to collect the needed emailadresses.

    Nic;o)

    Comment

    • HyBry
      New Member
      • Sep 2007
      • 40

      #3
      Hey nico5038
      I tried the DB you gave me and it works fine and it has what I need, I think.
      Problem is that when I take the code and copy it it does not work. I created a text field txtSelected. As I have no use for the top and height ones I removed them from the code. Anyhow, when I make a selection debugger shows Type mismatch and highlights Set rs = me.recordesetcl one line!
      How can I fix this?? any ideas? btw I use Access 2000

      Comment

      • HyBry
        New Member
        • Sep 2007
        • 40

        #4
        Ok... I got some of it to work with a bit of different code... scavenged all I know together and came up with this
        Code:
        Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        
        Parent.txtSelected = ""
        ' set variable to check selection height against
        intI = 0
        ' record user made selection to reproduce it later
        st = Me.SelTop
        sh = Me.SelHeight
        
        ' loop condition to check for multiple selections
        While intI < Me.SelHeight
        ' add values to the end of the list
         Parent.txtSelected = Parent.txtSelected & Me.[e-Mail] & "; "
        'Selection top and height adjustment after new value has been recorded.
         Me.SelHeight = Me.SelHeight - 1
         Me.SelTop = Me.SelTop + 1
        Wend
        
        ' restore original selection
        Me.SelTop = st
        Me.SelHeight = sh
        
        End Sub
        Just two problems with this.
        One of them unfortunately is HUGE one. It works fine if I select a row or multiple rows. I can click in any field and it is ok, but as soon as I select a whole column by clicking on header it crashes - well freezes..
        The other issue is that if I click in any field, and do not select the whole row it does not recognize selection. and keeps the old one.

        Comment

        • nico5038
          Recognized Expert Specialist
          • Nov 2006
          • 3080

          #5
          Hmm, almost there I see :-)
          The problems you experience are due to not testing the SelStart and SelHeight to hold a valid value.
          Incase there's just 1 row you'll need to use the Current row's value (just refer to the Me.FieldYouNeed )

          Getting the idea ?

          Nic;o)

          Comment

          • HyBry
            New Member
            • Sep 2007
            • 40

            #6
            Still haven't had any more success with this...
            Oh well... there are more important things to do... so I am gonna have to come back to this later I suppose...
            But thanks for the help Nic;o) learned some good things form you... :)

            Comment

            • nico5038
              Recognized Expert Specialist
              • Nov 2006
              • 3080

              #7
              I'll keep "listening" to this post, so feel free to post when ready :-)

              Nic;o)

              Comment

              • HyBry
                New Member
                • Sep 2007
                • 40

                #8
                Well, I couldn't sit still as this was bugging me. I rewrote the code and made some small changes that made lot of difference and found out what I need to do, I think
                Code:
                ST = Me.SelTop
                SH = Me.SelHeight
                SH1 = Me.SelHeight
                
                Parent.txtSelected = ""
                
                While SH1 > 0
                    Parent.txtSelected = Parent.txtSelected & Me.e_mail & "; "
                    SH1 = SH1 - 1
                    Me.SelTop = Me.SelTop + 1
                Wend
                Me.SelTop = ST
                Me.SelHeight = SH
                Selecting column now does not crash Access anymore! What I think I need to do is to set record that is me.seltop to currentrecord.
                Basically what I have now is that when I select a column it reads the right amount of records, but it only uses value from the first one. And second related thing I found out was that if I select records from bottom up, Access will take the bottom record first and go down.
                Lets say I have 3 records and I select 1;2 all is OK, but if I select 2;1 it will take values of 2; 3. I made a little test - created test field in main form to see SelTop and SelHeight values and they were correct.
                So what I think I have to do is to make it take value of record that corresponds to selTop, and it should solve bottom up selection and column selection problem. Any ideas hot to accomplish this, or any other ideas?

                Comment

                • nico5038
                  Recognized Expert Specialist
                  • Nov 2006
                  • 3080

                  #9
                  My code does always show the strings from "top to bottom":
                  [code=vb]
                  intI = 0

                  While intI < Me.SelHeight
                  Parent.txtSelec ted = Parent.txtSelec ted & " " & rs!Field1
                  intI = intI + 1
                  rs.MoveNext
                  Wend
                  [/code]

                  A selection won't be reset however when the user clicks inside a field!

                  Nic;o)

                  Comment

                  • HyBry
                    New Member
                    • Sep 2007
                    • 40

                    #10
                    I have some problem getting rs to work.
                    if I use:
                    Set rs=RecordSetClo ne it gives error of type mismatch while without it, it does not recognize what rs is...
                    Plus in your sample db it pops out an error when a column is selected rather than row!
                    So unless there is way to get info out of record that matches me.seltop and not me.currentrecor d then I will have to drop this...

                    Either way, thanks for the input.. learned a lot... :D

                    Comment

                    • nico5038
                      Recognized Expert Specialist
                      • Nov 2006
                      • 3080

                      #11
                      You'll need to tell which recordset like:
                      Set rs= Me.RecordSetClo ne
                      or
                      Set rs=Me.Subformna me.RecordSetClo ne

                      Also make sure rs is defined as a DAO.recordset with a DIM statement !

                      Nic;o)

                      Comment

                      • HyBry
                        New Member
                        • Sep 2007
                        • 40

                        #12
                        Found out where I had a problem and why it didn't like your code... I had DAO library turned off.. enabled it and it works fine... except for one thing:
                        Is it possible to enable it to work when a column is selected? If a select a column it gives an error that there is no current record!!

                        Comment

                        • nico5038
                          Recognized Expert Specialist
                          • Nov 2006
                          • 3080

                          #13
                          Can't reproduce the error. When I select a column in my sample .mdb the SelStart and SelLength indicate all records.....

                          Nic;o)

                          Comment

                          • HyBry
                            New Member
                            • Sep 2007
                            • 40

                            #14
                            I get an error 'current record not found' on this line:
                            Code:
                             Parent.txtSelected = Parent.txtSelected & rs!Mail & "; "
                            also in you sample DB. I am using A2000 so it is whether that or some setting is not turned on again...

                            Comment

                            • nico5038
                              Recognized Expert Specialist
                              • Nov 2006
                              • 3080

                              #15
                              Guess you need to check indeed the Tools/References for a reference to the DAO library.

                              Nic;o)

                              Comment

                              Working...