Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Dec 2011
    Thanked 0 Times in 0 Posts

    Select Statement Array Trouble

    I have a newsletter program I'm trying to use a group list like 1,2,3,4 in my database to send email to one or more groups. So I get the groups say 1,2 but when I try to get the email address from a user say in group 1 I get nothing. I believe it not finding the 1 in the list of 1,2,3 if the user is in those groups. Here's what I have:

    NMGroups = Replace(UploadFormRequest("txtGroup"), " ", "") 'remove white space
    strSQL = "SELECT * FROM NewsletterMembers WHERE NMActive = 'True' AND NMGroups IN ('" & NMGroups & "')"
    Set sendemails = database.Execute(strSQL)
    Thanks for your help in advance!!!!

  2. #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Thanked 4,947 Times in 4,908 Posts
    I *TOLD* you that using a delimited list in a single field WILL NOT WORK.

    If this line of code:
    NMGroups = Replace(UploadFormRequest("txtGroup"), " ", "")
    results in the variable NMGroups having the value of "1,2,3,4" then the *ONLY* records that will match in your query are those where the field in the database is *EXACTLY* 1,2,3,4 !!!

    It WILL NOT MATCH "1,2,3". It WILL NOT MATCH "1,2,3,4,5". It WILL NOT MATCH "1".

    One more time: Your lack of understanding of correct database design has led you into a corner. You can't get out of this one.
    Be yourself. No one else is as qualified.


Posting Permissions

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