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 / Forms Programming / July 2005

Tip: Looking for answers? Try searching our database.

Running parameter query from code problems.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gibson - 19 Jul 2005 17:27 GMT
I'm trying to use the following code to run a query that will return only
the records where Field1 in the query is equal to strField1(a variable I
define).  When I run the code I receive a Item Not Found In Collection error
at the line where I Set the prm. to Field1. I do not have anything in the
criteria of Field1 in qry1 because  I don't know what to put in there. I
can't reference a variable set behind the form there, can I?   I've never
used this type of code before and am obviously in the dark.  Thanks for any
suggestions.

       Dim qdf As DAO.QueryDef
       Dim prm As DAO.Parameter

       Set qdf = db.QueryDefs(qry1)
       Set prm = qdf.Parameters![Field1]
'Set parameter value
       prm = strField1
'Execute QueryDef to produce a recordset
       Set rs = qdf.OpenRecordset
Klatuu - 19 Jul 2005 17:58 GMT
Dim qdf As DAO.QueryDef
Dim rst as Recordset

   Set qdf = db.QueryDefs(qry1)
   qdf.Parameters(0) = strField1
   set rst = qdf.OpenRecordSet
   if Not rst.EOF Then
       rst.MoveLast
       rst.MoveFirst
   End If

> I'm trying to use the following code to run a query that will return only
> the records where Field1 in the query is equal to strField1(a variable I
[quoted text clipped - 14 lines]
> 'Execute QueryDef to produce a recordset
>         Set rs = qdf.OpenRecordset
 
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.