Results 1 to 11 of 11
  1. #1
    nickblitz is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    21

    ignoring null value in recordset

    i have this code here to send out email... it works fine but it does not skip through the blank spaces in the recordset.

    can anyone help me?
    how do i incorporate the find null thing into this??


    Private Sub Command35_Click()
    Dim MyDb As DAO.Database
    Dim rsEmail As DAO.Recordset


    Dim strEmailAddress


    Set MyDb = CurrentDb()
    Set rsEmail = MyDb.OpenRecordset("Query Full Director", dbOpenSnapshot)


    Do Until rsEmail.EOF
    strEmailAddress = strEmailAddress & rsEmail("Secondary Email") & ";"
    rsEmail.MoveNext
    Loop


    strEmailAddress = Left(strEmailAddress, Len(strEmailAddress) - 1)


    DoCmd.SendObject , , acFormatRTF, strEmailAddress, _
    , , strSubject, strEMailMsg, True, False


    rsEmail.Close
    Set rst = Nothing


    End Sub

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    What do you mean by 'blank spaces' - there is no email address in the record?

    Options:

    1. Filter in query to exclude records that don't have email

    2. Code
    If Not IsNull(rsEmail("Secondary Email")) Then
    'send email
    ...
    End If
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    nickblitz is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    21
    Quote Originally Posted by June7 View Post
    What do you mean by 'blank spaces' - there is no email address in the record?

    Options:

    1. Filter in query to exclude records that don't have email

    2. Code
    If Not IsNull(rsEmail("Secondary Email")) Then
    'send email
    ...
    End If
    Hi June,

    thanks for your reply.
    i added the code you posted above in. it does not have errors but when i clicked the button, nothing happened. no pop ups from outlook at all.

    yeah there are blank records in my table.

    i would much prefer a code that does that.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Post your complete procedure or provide db for analysis. Follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    nickblitz is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    21
    Quote Originally Posted by June7 View Post
    Post your complete procedure or provide db for analysis. Follow instructions at bottom of my post.
    that was my complete code.. ??

    included with attachment.

    theres a query full director form.

    theres a command button that selects the secondary email and opens up outlook.

  6. #6
    nickblitz is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    21
    attachment
    Attached Files Attached Files

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I looked at the code behind each form and none show the If Then code I suggested.

    Why have 7 identical forms for emailing? Have one form that can be filtered to show the desired records.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    nickblitz is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    21
    Quote Originally Posted by June7 View Post
    I looked at the code behind each form and none show the If Then code I suggested.

    Why have 7 identical forms for emailing? Have one form that can be filtered to show the desired records.
    i didnt add it in because it does not work.. can you help to see where i insert those codes into mine?

  9. #9
    nickblitz is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    21
    how is it? btw the queries are there search for specific records more easily to generate emails for different groups.

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Next time, provide the code you attempted, even if it is failing. For some reason the 'blank' Secondary Email field has a space when the code reads it so IsNull didn't work.
    Code:
    Do Until rsEmail.EOF
        If Len(rsEmail("Secondary Email") & "") > 1 Then
            strEmailAddress = strEmailAddress & rsEmail("Secondary Email") & ";"
        End If
        rsEmail.MoveNext
    Loop
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    nickblitz is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    21
    Quote Originally Posted by June7 View Post
    Next time, provide the code you attempted, even if it is failing. For some reason the 'blank' Secondary Email field has a space when the code reads it so IsNull didn't work.
    Code:
    Do Until rsEmail.EOF
        If Len(rsEmail("Secondary Email") & "") > 1 Then
            strEmailAddress = strEmailAddress & rsEmail("Secondary Email") & ";"
        End If
        rsEmail.MoveNext
    Loop
    thanks!!! it works! btw i was refering to the code you posted above. not my own codes.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 11
    Last Post: 11-09-2012, 08:17 AM
  2. Count Query w/o ignoring Nulls
    By Dulanic in forum Queries
    Replies: 3
    Last Post: 03-21-2012, 11:56 AM
  3. Replies: 2
    Last Post: 03-08-2012, 12:59 PM
  4. VBA excluding (Ignoring) Comma
    By RedWolf3x in forum Programming
    Replies: 3
    Last Post: 11-11-2011, 05:15 PM
  5. Replies: 0
    Last Post: 12-14-2009, 04:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums