No value given for one or more required parameters

D

DavidES

I keep getting an error that says, "No value given for one or more required
parameters" on the rs.Open line in the code below. The SQL for the query is
copied from a query and works great. I cannot figure out the problem.

This is a rewrite of some aircode I found on this discussion group. So the
main problem is I am working with something I don't fully understand. Your
help is greatly appreciated.

Dim rs As New ADODB.Recordset
rs.Open "SELECT UPS_CSV_EXPORT.Track FROM UPS_CSV_EXPORT
WHERE (((UPS_CSV_EXPORT.order) = [Forms]![EmailForm2]![order]) And
((UPS_CSV_EXPORT.Track) <= '9') And ((UPS_CSV_EXPORT.PUDate) > #9/17/2006#))
ORDER BY UPS_CSV_EXPORT.Track", CurrentProject.Connection, adOpenKeyset,
adLockOptimistic

strEmail = ""

Do While Not rs.EOF
strEmail = strEmail & rs!Track & " ; "
rs.MoveNext
Loop
 
K

Klatuu

The references to your form controls has to be outside the quotes:

rs.Open "SELECT UPS_CSV_EXPORT.Track FROM UPS_CSV_EXPORT
WHERE (((UPS_CSV_EXPORT.order) = '" & [Forms]![EmailForm2]![order] & "') And
((UPS_CSV_EXPORT.Track) <= '9') And ((UPS_CSV_EXPORT.PUDate) > #9/17/2006#))
ORDER BY UPS_CSV_EXPORT.Track", CurrentProject.Connection, adOpenKeyset,
adLockOptimistic


The above assumes UPS_CSV_EXPORT.order is a text field. It it is a numeric
field then you would not include the single quotes:

(UPS_CSV_EXPORT.order) = " & [Forms]![EmailForm2]![order] & ") And
 
D

DavidES

Thanks! Worked like a charm!

Klatuu said:
The references to your form controls has to be outside the quotes:

rs.Open "SELECT UPS_CSV_EXPORT.Track FROM UPS_CSV_EXPORT
WHERE (((UPS_CSV_EXPORT.order) = '" & [Forms]![EmailForm2]![order] & "') And
((UPS_CSV_EXPORT.Track) <= '9') And ((UPS_CSV_EXPORT.PUDate) > #9/17/2006#))
ORDER BY UPS_CSV_EXPORT.Track", CurrentProject.Connection, adOpenKeyset,
adLockOptimistic


The above assumes UPS_CSV_EXPORT.order is a text field. It it is a numeric
field then you would not include the single quotes:

(UPS_CSV_EXPORT.order) = " & [Forms]![EmailForm2]![order] & ") And

DavidES said:
I keep getting an error that says, "No value given for one or more required
parameters" on the rs.Open line in the code below. The SQL for the query is
copied from a query and works great. I cannot figure out the problem.

This is a rewrite of some aircode I found on this discussion group. So the
main problem is I am working with something I don't fully understand. Your
help is greatly appreciated.

Dim rs As New ADODB.Recordset
rs.Open "SELECT UPS_CSV_EXPORT.Track FROM UPS_CSV_EXPORT
WHERE (((UPS_CSV_EXPORT.order) = [Forms]![EmailForm2]![order]) And
((UPS_CSV_EXPORT.Track) <= '9') And ((UPS_CSV_EXPORT.PUDate) > #9/17/2006#))
ORDER BY UPS_CSV_EXPORT.Track", CurrentProject.Connection, adOpenKeyset,
adLockOptimistic

strEmail = ""

Do While Not rs.EOF
strEmail = strEmail & rs!Track & " ; "
rs.MoveNext
Loop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top