Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / January 2006

Tip: Looking for answers? Try searching our database.

Help, Error.  Too Few....

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ben Adams - 18 Jan 2006 20:45 GMT
Trying to Export items from a Query "CalenderExport Q" (See Query Below) that
uses imputs from a combo box in a form.  Using a function to export the
records to Outlook - However, When it gets to Set rst =
oDataBase.OpenRecordset("CalendarExport Q"), it gives me an error "Too Few
parameters. Expected 3."  How can I have it call the records that show when I
open the query?

Function ExportCalendartoOutlook()

Dim oDataBase As DAO.Database
Dim rst As DAO.Recordset
Set oDataBase = CurrentDb
Set rst = oDataBase.OpenRecordset("CalendarExport Q")

More code here, doesn't matter.....

End Function

CalendarExport Q

SELECT [Master Planned].Date, [Activity] & " / " & [Vendor] & " / " &
[Customer Forecasts]!Name AS Subject, [Master Planned].Comments AS Body,
"Sales Plan" AS Category
FROM [Branch Master] LEFT JOIN ([Customer Forecasts] RIGHT JOIN [Master
Planned] ON [Customer Forecasts].[Customer ID] = [Master Planned].[Customer
ID]) ON [Branch Master].[Branch ID] = [Master Planned].[Branch ID]
WHERE ((([Master Planned].Date) Is Not Null) AND
((IIf([Forms]![CalendarExport]![Vendor] Is Not
Null,[Vendor]=[Forms]![CalendarExport]![Vendor],[Vendor] Is Not
Null))<>False) AND ((IIf([Forms]![CalendarExport]![Activity] Is Not
Null,[Activity]=[Forms]![CalendarExport]![Activity],[Activity] Is Not
Null))<>False) AND ((IIf([Forms]![CalendarExport]![Salesperson] Is Not
Null,[Salesperson]=[Forms]![CalendarExport]![Salesperson],[Salesperson] Is
Not Null))<>False))
ORDER BY [Master Planned].Date;
Alex Dybenko - 19 Jan 2006 05:36 GMT
Hi, you have to either supply parameters for query, or just replace them
with values, when you build SQL:

strSQL="SELECT [Master Planned].Date ... WHERE ((([Master Planned].Date) Is
Not Null) AND
((IIf(" & [Forms]![CalendarExport]![Vendor] & " Is Not Null,[Vendor]=" &
[Forms]![CalendarExport]![Vendor],[Vendor] & " Is Not ...."

Set rst = oDataBase.OpenRecordset(strSQL)

pls note that if parameter has string value - then it should be enclosed in
quotes:

..((IIf('" & [Forms]![CalendarExport]![Vendor] & "' Is ...

Signature

Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

> Trying to Export items from a Query "CalenderExport Q" (See Query Below)
> that
[quoted text clipped - 34 lines]
> Not Null))<>False))
> ORDER BY [Master Planned].Date;
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.