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 2006

Tip: Looking for answers? Try searching our database.

Recordset or Query object?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peter Clancy - 20 Nov 2006 15:01 GMT
I have a form in which the user selects search criteria and enters values for
that criteria. I can use that to build a select sql string easily enough but
after this I seem to be having a mental blank. Should I use the sql string to
generate a recordset, or should I store it as a query object (overwriting say
a generic query) and execute the query object.  Whatever the method I want to
display the result in a datasheet format.
Thanks
Peter
Allen Browne - 20 Nov 2006 15:58 GMT
Just assign the SQL string you created to the RecordSource property of the
form to get the results you want.

Example:
   Dim strSql As String
   strSql = "SELECT * FROM Table1 WHERE City = ""Seattle"";"
   Forms!Form1.RecordSource = strSql

Signature

Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

>I have a form in which the user selects search criteria and enters values
>for
[quoted text clipped - 9 lines]
> Thanks
> Peter
Peter Clancy - 20 Nov 2006 16:38 GMT
Ok, this is why I was considering going down the save it as a query and
execute the query route. I have never designed a form in a datasheet format
before and dont know how to do it. Also I am anticipating building a
configuration form that will allow the user to select which fields they wish
to display in the output, so I thought if I save it as a query and execute
the query, the default behavior to display the results of a query is in a
datasheet mode (except that I am getting an error about running a select
query when I try this method).  I dont know if it is possible to just display
a recordset in a similar manner.

> Just assign the SQL string you created to the RecordSource property of the
> form to get the results you want.
[quoted text clipped - 17 lines]
> > Thanks
> > Peter
Allen Browne - 21 Nov 2006 01:02 GMT
No worries. If you would prefer to assign the query, you could create one
for the purpose, and then assign the SQL statement to the QueryDef, e.g.:

   CurrentDb.Querydefs("Query1").SQL = strSql

Signature

Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

> Ok, this is why I was considering going down the save it as a query and
> execute the query route. I have never designed a form in a datasheet
[quoted text clipped - 36 lines]
>> > Thanks
>> > Peter
 
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.