Too few parameters?

P

PayeDoc

Hello All

I have the function below, which used to work fine, but now when I try to
run it I get runtime error 3061 and a message saying that there are "too few
parameters - expected 1". The code stops on the line
Set rstS = CurrentDb.OpenRecordset("select * from
[qry_client_organisation_for_email]")

Hope someone can help.
Many thanks
Leslie Isaacs


Public Function EmailIndivCircular()
Dim rstS As Recordset
Const strReport = "rpt missing wrong fees letter only"
Const strFilePrefix = "Z:\Client_Reports\TempPayslips\IndivCircular "
Dim strFileName As String

DoCmd.OpenForm "frm practices"


Set rstS = CurrentDb.OpenRecordset("select * from
[qry_client_organisation_for_email]")

With rstS
If .RecordCount Then
.MoveFirst
Do Until .EOF
mstrPracticeToEmail = ![prac name]
[Forms]![frm x main]![prac name] = rstS![prac name]
strFileName = strFilePrefix & mstrPracticeToEmail &
".pdf"
ConvertReportToPDF strReport, vbNullString, strFileName,
False
SendJmail !email, _
"", _
"(e-mail address removed)", _
"Account details", _
"Please see attached letter regarding your
account." & vbCrLf & vbCrLf & "Kind regards" & vbCrLf & "Leslie Isaacs" &
vbCrLf & "PayeDoc", _
strFileName

Kill strFileName
.MoveNext
Loop
End If
End With

ExitHere:
On Error Resume Next
rstS.Close
Set rstS = Nothing
End Function
 
D

Douglas J. Steele

Odds are you've got references to both ADO and DAO in your database, but
your code is using a DAO recordset. To ensure that's what rstS gets defined
as, you need to disambiguate:

Dim rstS As DAO.Recordset

If that raises an error about undefined user type, while you're in the VB
Editor, select Tools | References from the menu and make sure that the
reference for Microsoft DAO 3.6 Object Library is selected.
 
P

PayeDoc

Hello Douglas

Many thanks for your reply.

I amended Dim rstS As Recordset to Dim rstS As DAO.Recordset, but still get
exactly the same error (nothing about undefined user type). I did check that
Microsoft DAO 3.6 Object Library is selected, and it is.

Pity - I really like the word "disambiguate"!!

If you have any other suggestions I can try I would be really grateful.

Thanks agin
Les




Douglas J. Steele said:
Odds are you've got references to both ADO and DAO in your database, but
your code is using a DAO recordset. To ensure that's what rstS gets defined
as, you need to disambiguate:

Dim rstS As DAO.Recordset

If that raises an error about undefined user type, while you're in the VB
Editor, select Tools | References from the menu and make sure that the
reference for Microsoft DAO 3.6 Object Library is selected.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


PayeDoc said:
Hello All

I have the function below, which used to work fine, but now when I try to
run it I get runtime error 3061 and a message saying that there are "too
few
parameters - expected 1". The code stops on the line
Set rstS = CurrentDb.OpenRecordset("select * from
[qry_client_organisation_for_email]")

Hope someone can help.
Many thanks
Leslie Isaacs


Public Function EmailIndivCircular()
Dim rstS As Recordset
Const strReport = "rpt missing wrong fees letter only"
Const strFilePrefix = "Z:\Client_Reports\TempPayslips\IndivCircular "
Dim strFileName As String

DoCmd.OpenForm "frm practices"


Set rstS = CurrentDb.OpenRecordset("select * from
[qry_client_organisation_for_email]")

With rstS
If .RecordCount Then
.MoveFirst
Do Until .EOF
mstrPracticeToEmail = ![prac name]
[Forms]![frm x main]![prac name] = rstS![prac name]
strFileName = strFilePrefix & mstrPracticeToEmail &
".pdf"
ConvertReportToPDF strReport, vbNullString,
strFileName,
False
SendJmail !email, _
"", _
"(e-mail address removed)", _
"Account details", _
"Please see attached letter regarding your
account." & vbCrLf & vbCrLf & "Kind regards" & vbCrLf & "Leslie Isaacs" &
vbCrLf & "PayeDoc", _
strFileName

Kill strFileName
.MoveNext
Loop
End If
End With

ExitHere:
On Error Resume Next
rstS.Close
Set rstS = Nothing
End Function
 
V

vanderghast

If your query qry_client_organisation_for_email has a parameter of the form
FORMS!formName!ControlName, then CurrentDb won't resolve it for you,
automatically (while the User Interface, and DoCmd, and DLookup (and other
"Domain" functions), and record/row source properties would.

See http://www.mvps.org/access/queries/qry0013.htm.



Vanderghast, Access MVP
 
P

PayeDoc

Hello "Vanderghast"

Got it!!

To be honest I didn't really understand much of what was said at the
reference you gave, but I did get the bit about problems accessing form
controls as parameters. In fact my query qry_client_organisation_for_email
didn't itself refer to any such form controls, but it is based on another
query that does. When I remove the reference to the form control (by
hard-coding the parameter) ... all is well!!

All I need to think about now is how to restore the reference to the form
control, because the hard-coded parameter will not be useful in the long
term. If you could help me (in idiot-proof language) do that I would be
really grateful (not that I'm not really grateful already!).

Many thanks
Les



vanderghast said:
If your query qry_client_organisation_for_email has a parameter of the form
FORMS!formName!ControlName, then CurrentDb won't resolve it for you,
automatically (while the User Interface, and DoCmd, and DLookup (and other
"Domain" functions), and record/row source properties would.

See http://www.mvps.org/access/queries/qry0013.htm.



Vanderghast, Access MVP




PayeDoc said:
Hello All

I have the function below, which used to work fine, but now when I try to
run it I get runtime error 3061 and a message saying that there are "too
few
parameters - expected 1". The code stops on the line
Set rstS = CurrentDb.OpenRecordset("select * from
[qry_client_organisation_for_email]")

Hope someone can help.
Many thanks
Leslie Isaacs


Public Function EmailIndivCircular()
Dim rstS As Recordset
Const strReport = "rpt missing wrong fees letter only"
Const strFilePrefix = "Z:\Client_Reports\TempPayslips\IndivCircular "
Dim strFileName As String

DoCmd.OpenForm "frm practices"


Set rstS = CurrentDb.OpenRecordset("select * from
[qry_client_organisation_for_email]")

With rstS
If .RecordCount Then
.MoveFirst
Do Until .EOF
mstrPracticeToEmail = ![prac name]
[Forms]![frm x main]![prac name] = rstS![prac name]
strFileName = strFilePrefix & mstrPracticeToEmail &
".pdf"
ConvertReportToPDF strReport, vbNullString,
strFileName,
False
SendJmail !email, _
"", _
"(e-mail address removed)", _
"Account details", _
"Please see attached letter regarding your
account." & vbCrLf & vbCrLf & "Kind regards" & vbCrLf & "Leslie Isaacs" &
vbCrLf & "PayeDoc", _
strFileName

Kill strFileName
.MoveNext
Loop
End If
End With

ExitHere:
On Error Resume Next
rstS.Close
Set rstS = Nothing
End Function
 
V

vanderghast

You want to get a recordset? Instead of using
CurrentDb.OpenRecordset(... ), you will use
QueryDefObject.OpenRecordset( ).




Dim myQueryDefObject As QueryDef
myQueryDefObject = QueryDefs("savedQueryNameHere"

Dim param As DAO.Parameter
foreach param in myQueryDefObject.Parameters
param.Value = eval(param.name)
next param

Dim rst AS DAO.recordset
Set rst = myQueryDef.OpenRecordset( ... wanted options here )







To work, that code assumes that:

- I didn't make any typo

- all your parameters are in the format of :
FORMS!formName!ControlName
so that eval( ... ) , on such name, simply pumps the value from the
control. That occurs in the strange line:


param = eval(param.Name)

or
param.Value = eval(param.Name)


if you prefer (since Value is the default property of a DAO.Parameter, if
memory serves).

Once your queryDef object now has a value for each of its parameters, none
will be 'Missing', but using the so filled querydef object,


Set rst=myQueryDefObject.OpneRecorset( ... )

not a brand new one, ie, not:

Set rst = QueryDefs("savedQueryName").OpenRecordset( ... )

which would then be quite the same as

Set rst=CurrentDb.OpenRecordset("savedQueryname", .... )





If param.Value = eval(param.Name) is not applicable, for some reason, you
still have to fill each parameter with a value, probably using a switch:

for each p in myQdf.Parameters

if(p.name="[ enter starting date] ") then
p.value = now
else if ...
...

else
p.value = eval(p.name)
end if

next p


as example.





Vanderghast, Access MVP



PayeDoc said:
Hello "Vanderghast"

Got it!!

To be honest I didn't really understand much of what was said at the
reference you gave, but I did get the bit about problems accessing form
controls as parameters. In fact my query qry_client_organisation_for_email
didn't itself refer to any such form controls, but it is based on another
query that does. When I remove the reference to the form control (by
hard-coding the parameter) ... all is well!!

All I need to think about now is how to restore the reference to the form
control, because the hard-coded parameter will not be useful in the long
term. If you could help me (in idiot-proof language) do that I would be
really grateful (not that I'm not really grateful already!).

Many thanks
Les



vanderghast said:
If your query qry_client_organisation_for_email has a parameter of the form
FORMS!formName!ControlName, then CurrentDb won't resolve it for you,
automatically (while the User Interface, and DoCmd, and DLookup (and
other
"Domain" functions), and record/row source properties would.

See http://www.mvps.org/access/queries/qry0013.htm.



Vanderghast, Access MVP




PayeDoc said:
Hello All

I have the function below, which used to work fine, but now when I try to
run it I get runtime error 3061 and a message saying that there are
"too
few
parameters - expected 1". The code stops on the line
Set rstS = CurrentDb.OpenRecordset("select * from
[qry_client_organisation_for_email]")

Hope someone can help.
Many thanks
Leslie Isaacs


Public Function EmailIndivCircular()
Dim rstS As Recordset
Const strReport = "rpt missing wrong fees letter only"
Const strFilePrefix = "Z:\Client_Reports\TempPayslips\IndivCircular
"
Dim strFileName As String

DoCmd.OpenForm "frm practices"


Set rstS = CurrentDb.OpenRecordset("select * from
[qry_client_organisation_for_email]")

With rstS
If .RecordCount Then
.MoveFirst
Do Until .EOF
mstrPracticeToEmail = ![prac name]
[Forms]![frm x main]![prac name] = rstS![prac name]
strFileName = strFilePrefix & mstrPracticeToEmail &
".pdf"
ConvertReportToPDF strReport, vbNullString,
strFileName,
False
SendJmail !email, _
"", _
"(e-mail address removed)", _
"Account details", _
"Please see attached letter regarding your
account." & vbCrLf & vbCrLf & "Kind regards" & vbCrLf & "Leslie Isaacs" &
vbCrLf & "PayeDoc", _
strFileName

Kill strFileName
.MoveNext
Loop
End If
End With

ExitHere:
On Error Resume Next
rstS.Close
Set rstS = Nothing
End Function
 
J

John Spencer MVP

It would help if you posted the SQL of all three queries. You posted the SQL
of the query at the failure point.
"select * from [qry_client_organisation_for_email]"

Perhaps the query can be built in VBA using subqueries.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
Hello "Vanderghast"

Got it!!

To be honest I didn't really understand much of what was said at the
reference you gave, but I did get the bit about problems accessing form
controls as parameters. In fact my query qry_client_organisation_for_email
didn't itself refer to any such form controls, but it is based on another
query that does. When I remove the reference to the form control (by
hard-coding the parameter) ... all is well!!

All I need to think about now is how to restore the reference to the form
control, because the hard-coded parameter will not be useful in the long
term. If you could help me (in idiot-proof language) do that I would be
really grateful (not that I'm not really grateful already!).

Many thanks
Les



vanderghast said:
If your query qry_client_organisation_for_email has a parameter of the form
FORMS!formName!ControlName, then CurrentDb won't resolve it for you,
automatically (while the User Interface, and DoCmd, and DLookup (and other
"Domain" functions), and record/row source properties would.

See http://www.mvps.org/access/queries/qry0013.htm.



Vanderghast, Access MVP




PayeDoc said:
Hello All

I have the function below, which used to work fine, but now when I try to
run it I get runtime error 3061 and a message saying that there are "too
few
parameters - expected 1". The code stops on the line
Set rstS = CurrentDb.OpenRecordset("select * from
[qry_client_organisation_for_email]")

Hope someone can help.
Many thanks
Leslie Isaacs


Public Function EmailIndivCircular()
Dim rstS As Recordset
Const strReport = "rpt missing wrong fees letter only"
Const strFilePrefix = "Z:\Client_Reports\TempPayslips\IndivCircular "
Dim strFileName As String

DoCmd.OpenForm "frm practices"


Set rstS = CurrentDb.OpenRecordset("select * from
[qry_client_organisation_for_email]")

With rstS
If .RecordCount Then
.MoveFirst
Do Until .EOF
mstrPracticeToEmail = ![prac name]
[Forms]![frm x main]![prac name] = rstS![prac name]
strFileName = strFilePrefix & mstrPracticeToEmail &
".pdf"
ConvertReportToPDF strReport, vbNullString,
strFileName,
False
SendJmail !email, _
"", _
"(e-mail address removed)", _
"Account details", _
"Please see attached letter regarding your
account." & vbCrLf & vbCrLf & "Kind regards" & vbCrLf & "Leslie Isaacs" &
vbCrLf & "PayeDoc", _
strFileName

Kill strFileName
.MoveNext
Loop
End If
End With

ExitHere:
On Error Resume Next
rstS.Close
Set rstS = Nothing
End Function
 
M

Mark

vanderghast

What if the parameters are in a nested query?
e.g.,
Query2 contains the final desired recordset, but Query2 is based upon Query1
which is the query that contains the parameters.

Mark

vanderghast said:
You want to get a recordset? Instead of using
CurrentDb.OpenRecordset(... ), you will use
QueryDefObject.OpenRecordset( ).




Dim myQueryDefObject As QueryDef
myQueryDefObject = QueryDefs("savedQueryNameHere"

Dim param As DAO.Parameter
foreach param in myQueryDefObject.Parameters
param.Value = eval(param.name)
next param

Dim rst AS DAO.recordset
Set rst = myQueryDef.OpenRecordset( ... wanted options here )







To work, that code assumes that:

- I didn't make any typo

- all your parameters are in the format of :
FORMS!formName!ControlName
so that eval( ... ) , on such name, simply pumps the value from the
control. That occurs in the strange line:


param = eval(param.Name)

or
param.Value = eval(param.Name)


if you prefer (since Value is the default property of a DAO.Parameter, if
memory serves).

Once your queryDef object now has a value for each of its parameters, none
will be 'Missing', but using the so filled querydef object,


Set rst=myQueryDefObject.OpneRecorset( ... )

not a brand new one, ie, not:

Set rst = QueryDefs("savedQueryName").OpenRecordset( ... )

which would then be quite the same as

Set rst=CurrentDb.OpenRecordset("savedQueryname", .... )





If param.Value = eval(param.Name) is not applicable, for some reason, you
still have to fill each parameter with a value, probably using a switch:

for each p in myQdf.Parameters

if(p.name="[ enter starting date] ") then
p.value = now
else if ...
...

else
p.value = eval(p.name)
end if

next p


as example.





Vanderghast, Access MVP



PayeDoc said:
Hello "Vanderghast"

Got it!!

To be honest I didn't really understand much of what was said at the
reference you gave, but I did get the bit about problems accessing form
controls as parameters. In fact my query qry_client_organisation_for_email
didn't itself refer to any such form controls, but it is based on another
query that does. When I remove the reference to the form control (by
hard-coding the parameter) ... all is well!!

All I need to think about now is how to restore the reference to the form
control, because the hard-coded parameter will not be useful in the long
term. If you could help me (in idiot-proof language) do that I would be
really grateful (not that I'm not really grateful already!).

Many thanks
Les



vanderghast said:
If your query qry_client_organisation_for_email has a parameter of the form
FORMS!formName!ControlName, then CurrentDb won't resolve it for you,
automatically (while the User Interface, and DoCmd, and DLookup (and
other
"Domain" functions), and record/row source properties would.

See http://www.mvps.org/access/queries/qry0013.htm.



Vanderghast, Access MVP




Hello All

I have the function below, which used to work fine, but now when I
try
to
run it I get runtime error 3061 and a message saying that there are
"too
few
parameters - expected 1". The code stops on the line
Set rstS = CurrentDb.OpenRecordset("select * from
[qry_client_organisation_for_email]")

Hope someone can help.
Many thanks
Leslie Isaacs


Public Function EmailIndivCircular()
Dim rstS As Recordset
Const strReport = "rpt missing wrong fees letter only"
Const strFilePrefix = "Z:\Client_Reports\TempPayslips\IndivCircular
"
Dim strFileName As String

DoCmd.OpenForm "frm practices"


Set rstS = CurrentDb.OpenRecordset("select * from
[qry_client_organisation_for_email]")

With rstS
If .RecordCount Then
.MoveFirst
Do Until .EOF
mstrPracticeToEmail = ![prac name]
[Forms]![frm x main]![prac name] = rstS![prac name]
strFileName = strFilePrefix & mstrPracticeToEmail &
".pdf"
ConvertReportToPDF strReport, vbNullString,
strFileName,
False
SendJmail !email, _
"", _
"(e-mail address removed)", _
"Account details", _
"Please see attached letter regarding your
account." & vbCrLf & vbCrLf & "Kind regards" & vbCrLf & "Leslie
Isaacs"
&
vbCrLf & "PayeDoc", _
strFileName

Kill strFileName
.MoveNext
Loop
End If
End With

ExitHere:
On Error Resume Next
rstS.Close
Set rstS = Nothing
End Function
 
D

Douglas J. Steele

I believe Jet is smart enough to handle that, but you'd have to try it to be
certain.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Mark said:
vanderghast

What if the parameters are in a nested query?
e.g.,
Query2 contains the final desired recordset, but Query2 is based upon
Query1
which is the query that contains the parameters.

Mark

vanderghast said:
You want to get a recordset? Instead of using
CurrentDb.OpenRecordset(... ), you will use
QueryDefObject.OpenRecordset( ).




Dim myQueryDefObject As QueryDef
myQueryDefObject = QueryDefs("savedQueryNameHere"

Dim param As DAO.Parameter
foreach param in myQueryDefObject.Parameters
param.Value = eval(param.name)
next param

Dim rst AS DAO.recordset
Set rst = myQueryDef.OpenRecordset( ... wanted options here )







To work, that code assumes that:

- I didn't make any typo

- all your parameters are in the format of :
FORMS!formName!ControlName
so that eval( ... ) , on such name, simply pumps the value from the
control. That occurs in the strange line:


param = eval(param.Name)

or
param.Value = eval(param.Name)


if you prefer (since Value is the default property of a DAO.Parameter, if
memory serves).

Once your queryDef object now has a value for each of its parameters,
none
will be 'Missing', but using the so filled querydef object,


Set rst=myQueryDefObject.OpneRecorset( ... )

not a brand new one, ie, not:

Set rst = QueryDefs("savedQueryName").OpenRecordset( ... )

which would then be quite the same as

Set rst=CurrentDb.OpenRecordset("savedQueryname", .... )





If param.Value = eval(param.Name) is not applicable, for some reason,
you
still have to fill each parameter with a value, probably using a switch:

for each p in myQdf.Parameters

if(p.name="[ enter starting date] ") then
p.value = now
else if ...
...

else
p.value = eval(p.name)
end if

next p


as example.





Vanderghast, Access MVP



PayeDoc said:
Hello "Vanderghast"

Got it!!

To be honest I didn't really understand much of what was said at the
reference you gave, but I did get the bit about problems accessing form
controls as parameters. In fact my query qry_client_organisation_for_email
didn't itself refer to any such form controls, but it is based on another
query that does. When I remove the reference to the form control (by
hard-coding the parameter) ... all is well!!

All I need to think about now is how to restore the reference to the form
control, because the hard-coded parameter will not be useful in the
long
term. If you could help me (in idiot-proof language) do that I would be
really grateful (not that I'm not really grateful already!).

Many thanks
Les



If your query qry_client_organisation_for_email has a parameter of the
form
FORMS!formName!ControlName, then CurrentDb won't resolve it for you,
automatically (while the User Interface, and DoCmd, and DLookup (and
other
"Domain" functions), and record/row source properties would.

See http://www.mvps.org/access/queries/qry0013.htm.



Vanderghast, Access MVP




Hello All

I have the function below, which used to work fine, but now when I try
to
run it I get runtime error 3061 and a message saying that there are
"too
few
parameters - expected 1". The code stops on the line
Set rstS = CurrentDb.OpenRecordset("select * from
[qry_client_organisation_for_email]")

Hope someone can help.
Many thanks
Leslie Isaacs


Public Function EmailIndivCircular()
Dim rstS As Recordset
Const strReport = "rpt missing wrong fees letter only"
Const strFilePrefix = "Z:\Client_Reports\TempPayslips\IndivCircular
"
Dim strFileName As String

DoCmd.OpenForm "frm practices"


Set rstS = CurrentDb.OpenRecordset("select * from
[qry_client_organisation_for_email]")

With rstS
If .RecordCount Then
.MoveFirst
Do Until .EOF
mstrPracticeToEmail = ![prac name]
[Forms]![frm x main]![prac name] = rstS![prac name]
strFileName = strFilePrefix & mstrPracticeToEmail &
".pdf"
ConvertReportToPDF strReport, vbNullString,
strFileName,
False
SendJmail !email, _
"", _
"(e-mail address removed)", _
"Account details", _
"Please see attached letter regarding your
account." & vbCrLf & vbCrLf & "Kind regards" & vbCrLf & "Leslie Isaacs"
&
vbCrLf & "PayeDoc", _
strFileName

Kill strFileName
.MoveNext
Loop
End If
End With

ExitHere:
On Error Resume Next
rstS.Close
Set rstS = Nothing
End Function
 
M

Mark

Doug,
I'll try it again to be sure, but before it reported missing parameters when
they were in the lower-level query. Course, there could have been something
else going on too.
Thanks,
Mark

Douglas J. Steele said:
I believe Jet is smart enough to handle that, but you'd have to try it to be
certain.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Mark said:
vanderghast

What if the parameters are in a nested query?
e.g.,
Query2 contains the final desired recordset, but Query2 is based upon
Query1
which is the query that contains the parameters.

Mark

vanderghast said:
You want to get a recordset? Instead of using
CurrentDb.OpenRecordset(... ), you will use
QueryDefObject.OpenRecordset( ).




Dim myQueryDefObject As QueryDef
myQueryDefObject = QueryDefs("savedQueryNameHere"

Dim param As DAO.Parameter
foreach param in myQueryDefObject.Parameters
param.Value = eval(param.name)
next param

Dim rst AS DAO.recordset
Set rst = myQueryDef.OpenRecordset( ... wanted options here )







To work, that code assumes that:

- I didn't make any typo

- all your parameters are in the format of :
FORMS!formName!ControlName
so that eval( ... ) , on such name, simply pumps the value from the
control. That occurs in the strange line:


param = eval(param.Name)

or
param.Value = eval(param.Name)


if you prefer (since Value is the default property of a DAO.Parameter, if
memory serves).

Once your queryDef object now has a value for each of its parameters,
none
will be 'Missing', but using the so filled querydef object,


Set rst=myQueryDefObject.OpneRecorset( ... )

not a brand new one, ie, not:

Set rst = QueryDefs("savedQueryName").OpenRecordset( ... )

which would then be quite the same as

Set rst=CurrentDb.OpenRecordset("savedQueryname", .... )





If param.Value = eval(param.Name) is not applicable, for some reason,
you
still have to fill each parameter with a value, probably using a switch:

for each p in myQdf.Parameters

if(p.name="[ enter starting date] ") then
p.value = now
else if ...
...

else
p.value = eval(p.name)
end if

next p


as example.





Vanderghast, Access MVP



Hello "Vanderghast"

Got it!!

To be honest I didn't really understand much of what was said at the
reference you gave, but I did get the bit about problems accessing form
controls as parameters. In fact my query qry_client_organisation_for_email
didn't itself refer to any such form controls, but it is based on another
query that does. When I remove the reference to the form control (by
hard-coding the parameter) ... all is well!!

All I need to think about now is how to restore the reference to the form
control, because the hard-coded parameter will not be useful in the
long
term. If you could help me (in idiot-proof language) do that I would be
really grateful (not that I'm not really grateful already!).

Many thanks
Les



If your query qry_client_organisation_for_email has a parameter of the
form
FORMS!formName!ControlName, then CurrentDb won't resolve it for you,
automatically (while the User Interface, and DoCmd, and DLookup (and
other
"Domain" functions), and record/row source properties would.

See http://www.mvps.org/access/queries/qry0013.htm.



Vanderghast, Access MVP




Hello All

I have the function below, which used to work fine, but now when I try
to
run it I get runtime error 3061 and a message saying that there are
"too
few
parameters - expected 1". The code stops on the line
Set rstS = CurrentDb.OpenRecordset("select * from
[qry_client_organisation_for_email]")

Hope someone can help.
Many thanks
Leslie Isaacs


Public Function EmailIndivCircular()
Dim rstS As Recordset
Const strReport = "rpt missing wrong fees letter only"
Const strFilePrefix = "Z:\Client_Reports\TempPayslips\IndivCircular
"
Dim strFileName As String

DoCmd.OpenForm "frm practices"


Set rstS = CurrentDb.OpenRecordset("select * from
[qry_client_organisation_for_email]")

With rstS
If .RecordCount Then
.MoveFirst
Do Until .EOF
mstrPracticeToEmail = ![prac name]
[Forms]![frm x main]![prac name] = rstS![prac name]
strFileName = strFilePrefix &
mstrPracticeToEmail
&
".pdf"
ConvertReportToPDF strReport, vbNullString,
strFileName,
False
SendJmail !email, _
"", _
"(e-mail address removed)", _
"Account details", _
"Please see attached letter regarding your
account." & vbCrLf & vbCrLf & "Kind regards" & vbCrLf & "Leslie Isaacs"
&
vbCrLf & "PayeDoc", _
strFileName

Kill strFileName
.MoveNext
Loop
End If
End With

ExitHere:
On Error Resume Next
rstS.Close
Set rstS = Nothing
End Function
 

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

Similar Threads


Top