DB Openrecordset on Query

JSalle0826

Registered User.
Local time
, 19:32
Joined
Mar 7, 2012
Messages
14
Hello all,

Another issue---I think I've figured out what I need to do, but I will explain....I have a multi-select list box in which employees select departments to send a form as an attachment in an email. The results of this are generated in a Query (EmployeeQuery2). I created another Query (EmployeeQuery3) which only shows the results that are kept in EmployeeQuery2. When I do the OpenRecordset, I keep getting a Run-Time Error that states "Too few parameters. Expected 1".

What am I doing wrong here? I don't have much experience with VBA, let alone doing a Recordset from a Query.

Here is the option of my code:

Set DB = CurrentDb()
Set rst = DB.OpenRecordset("EmployeeQuery3", dbOpenForwardOnly)
With rst
Do While Not .EOF
strBuild = strBuild & ![Addy] & ";"
.MoveNext
Loop
End With


Any help that anyone could provide would be most appreciated.

Thanks.
 
If you have a multi-select textbox then you can run the loop in the listbox itself like this:


Code:
Dim i As Integer, strEmailTO as string
For i = 0 To Me.ListName.ListCount - 1
If Me.ListName.Selected(i) = -1 Then
    strEmailTO = strEmailTO & [wherever your email address is stored] & "; "
End If
Next i
 

Users who are viewing this thread

Back
Top Bottom