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 / November 2007

Tip: Looking for answers? Try searching our database.

Trying to write a select statement in VBA; Access 2002

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jim H - 30 Nov 2007 20:01 GMT
Hi, looking for a little help.  I'm writing some code in VBA, (database is
Access 2002).  What I want to do is a select statement where I have the
"Where" value set to a variable.  What I'm writing is this:

Dim db As DAO.Database
Dim strSQL As String
Set db = CurrentDb()

   strSQL = " SELECT DISTINCTROW tblBADataEntry.* "
   strSQL = strSQL + "FROM tblBADataEntry "
   strSQL = strSQL + "WHERE tblBADataEntry.[Request ID]= " &
txtSelectedProject
   Set ds = db.CreateDynaset(strSQL)

Wondering if I have to set a particular reference to allow this to work and
if so which one?  In my globals I've declared ds as a dynaset but when I
compile I also get an error message that says Dynaset a user defined type not
defined.  

How can I do a select statement like this??

thanks,
Jim
Ed Metcalfe - 30 Nov 2007 21:03 GMT
> Hi, looking for a little help.  I'm writing some code in VBA, (database is
> Access 2002).  What I want to do is a select statement where I have the
[quoted text clipped - 21 lines]
> thanks,
> Jim

Try:

Dim ds as DAO.Recordset
Set ds = db.OpenRecordset(strSQL, dbOpenDynaset)

Ed Metcalfe.
 
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.