too few parameters

S

Stephanie

Greetings! I have code that loops through my db to create a DoCmd.SendObject
email list based on a query. However, I can't figure out how to address the
DateDiff input paramater required by the query, READRegExpEmail:
Months since Expiration:
DateDiff("m",Max([RegREADResults].[RegREADDate]),[Reference date for
Registration: (MM/DD/YY)],True)

The looped code:
Private Sub RegExp_Click()
Dim rst As DAO.Recordset
Dim strTo As String
Set rst = CurrentDb.OpenRecordset("SELECT [EmailName] FROM
READRegExpEmail")
With rst
Do Until .EOF
strTo = strTo & ![EmailName] & ";"
.MoveNext
Loop
.Close
End With
strTo = Left(strTo, Len(strTo) - 1)
Set rst = Nothing
'line that would open Outlook to a new message with the bcc:
'box populated with the list you built in strTo
DoCmd.SendObject acSendNoObject, , , , , strTo, "R.E.A.D. registration
overdue"
End Sub

I appreciate help in incorporating the query parameter into the form code.
Thanks.
 
S

strive4peace

SQL, Error Handler, compile
---


Hi Stephanie,

what is the SQL for READRegExpEmail?

from your subject line (too few parameters), I am guessing that
[EmailName] may not be filled out on all the records

Add an error handler to your code

put this at the top of your program, right after the procedure
declaration (skip a line first for better readability)

'~~~~~~~~~~~~~~~~~~~~~~
On Error GoTo Proc_Err

'~~~~~~~~~~~~~~~~~~~~~~
... then your statements
'~~~~~~~~~~~~~~~~~~~~~~

put this at the end of the program

'~~~~~~~~~~~~~~~~~~~~~~
Proc_Exit:
On Error Resume Next
'release object variables if any
Exit Function

Proc_Err:
MsgBox Err.Description, , _
"ERROR " & Err.Number _
& " ProcedureName"

'press F8 to step through code and debug
'remove next line after debugged
Stop: Resume
Resume Proc_Exit

'~~~~~~~~~~~~~~~~~~~~~~

where
ProcedureName is the name of your procedure (RegExp_Click) so you can
identify what code the problem is in when you see the error

While I am developing, I like to make the error handler go to the line
that caused the problem so I can see where it is. Stop will stop the
code and Resume goes back to the offending line. When code Stops, press
F8 to execute one statement at a time.

The line labels do not matter (Proc_Exit:, Proc_Err:), I like to use the
same ones all the time -- they only have to be unique within a procedure.

'~~~~~~~~~ Compile ~~~~~~~~~

Whenever you change code or references, your should always compile
before executing.

from the menu in a module window: Debug, Compile

fix any errors on the yellow highlighted lines

keep compiling until nothing happens (this is good!)



Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
 

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