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 / New Users / March 2005

Tip: Looking for answers? Try searching our database.

Beginner Code and Query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SQUILIKI - 25 Mar 2005 20:01 GMT
Need a jump start here.
What is the syntax for calling a query in VB and how do you then reference
the various fieldsin the query.I am running Access 2002.

Query name: Test
Filed names: f1, f2, f3

tHANKS;
STEVE
Mark - 25 Mar 2005 23:47 GMT
Set a recordset object equal to the query and then reference the fields.
****untested air code, but you get the idea***  :)

Sub TestRecordset()
   Dim rst as DAO.Recordset
   Dim db as DAO.Database
   Set db=CurrentDB
   Set rst=db.OpenRecordset("Test", dbOpenSnapshot)
'dbOpenSnapshot is to open read-only so you can't accidentally
'alter any data in the recordset.  Use 'dbOpenDynaset' if you want
'to make changes to the data
   With rst
       .MoveFirst
       'print contents of field f1 to the immediate window
       Debug.Print !f1
       'print contents of f2 and f3 separated by a space
       Debug.Print !f2 & " " & !f3
   End With
   Set rst=Nothing
   Set db=Nothing
End Sub

> Need a jump start here.
> What is the syntax for calling a query in VB and how do you then reference
[quoted text clipped - 5 lines]
> tHANKS;
> STEVE
SQUILIKI - 26 Mar 2005 09:27 GMT
Hi Mark,
That was it . Thanks

> Set a recordset object equal to the query and then reference the fields.
> ****untested air code, but you get the idea***  :)
[quoted text clipped - 27 lines]
> > tHANKS;
> > STEVE
 
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.