Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Error - Too Few Parameters

Status
Not open for further replies.

ckennerdale

Programmer
Dec 23, 2000
158
GB
I am sending an email directly from a form.
So far I have been able to extractall email address from a database and send.

What I want to do is allocate a particular distribution list to each record in the database, and then select hich list to send to via a pull down form.

However I get the message 'Parameter missing, Expected 2' when I execute my code - which seems to be on the SQL statement. I am not sure what this error means so it is difficult to double check.

Here is the code

strSQL = "SELECT * FROM Distribution_Contacts WHERE Distribution_Contacts.[Distribution_List] = Me!DistributionList"
Set rs = dbs.OpenRecordset(strSQL)

Do Until rs.EOF
If Len(MyEmails) = 0 Then
MyEmails = rs! & rs![Distribution_List] & Me!DistributionList
Else
MyEmails = MyEmails & ";" & rs![Email] & rs![Distribution_List] & Me!DistributionList
End If
rs.MoveNext
Loop

(Distribution_Contacts = Database
[Distribution_List] = Field containing which list they belong to]
Me!DistributionList = drop down filed in form)

Any ideas on what the error is if it is a syntax error or what the sql error means?

Thanks

Caspar Kennerdale
 
You've included a reference to Me! in the SQL. By the time the sql processor gets ahold of it, Me is out of scope. When you refer to Me in a SQL statement that's in code behind a form, you have to do it outside the quotes:

strSQL = "SELECT * FROM Distribution_Contacts WHERE Distribution_Contacts.[Distribution_List] = " & Me!DistributionList

Jeremy

==
Jeremy Wallace
AlphaBet City Dataworks
Access Databases for Non-Profit Organizations

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top