Results 1 to 4 of 4
  1. #1
    workindan is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2010
    Posts
    8

    ADO Recordset.Open (SQL) does nothing

    Can anyone tell me why the select query doesn't pop up? I get the msgbox, so I know the code is running, but the recordset.open command produces nothing. What's wrong? Here's my code:

    Private Sub Search_Click()
    ' Set up ADO Recordset and Connection


    ' ================================================
    Dim myConnection As ADODB.Connection
    Set myConnection = CurrentProject.Connection
    Dim myRecordset As New ADODB.Recordset
    myRecordset.ActiveConnection = myConnection
    ' ================================================
    '
    Dim strOps, strEvent, strArea As Integer
    Dim mySQL As String

    mySQL = "SELECT ReliabilityEvents.IncidentID, ReliabilityEvents.Operation, ReliabilityEvents.TypeofEvent, ReliabilityEvents.Area FROM ReliabilityEvents;"
    myRecordset.Open mySQL, , adOpenStatic, adLockOptimistic
    MsgBox mySQL
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    What is it you're expecting to happen? That should open a recordset, but unless you actually do something with it, nothing visible will happen. If you're expecting to see the results, you don't want a recordset. Set the source of a form or subform to that SQL or something like that. A recordset is generally for working with data behind the scenes.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    workindan is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2010
    Posts
    8
    Thank you - this makes sense. Alright, so my question is just: how do I get the results to show somewhere, maybe in a form? That's all I want to do.

    Is there a good resource to learn how to control (via vba) access forms/queries/form controls, etc? I'm familiar with vba, been using it in excel for a while, but I'm still new to access dev. Any help or suggestions on what to read would be helpful. I've already poured through a for-dummies 9-in-1 reference book. Good primer, but doesn't cover my needs.

    Thanks everyone, and thanks pbaldy!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You could simply make that SQL the record source of a form. In the form's properties, the Record Source property is on the Data tab.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 02-26-2010, 08:14 AM
  2. Replies: 1
    Last Post: 11-13-2009, 03:03 AM
  3. This Recordset Is Not Updateable
    By botts121 in forum Access
    Replies: 1
    Last Post: 11-11-2009, 05:43 PM
  4. ADO.Recordset - Write
    By Marvin in forum Programming
    Replies: 0
    Last Post: 07-17-2009, 07:56 AM
  5. Replies: 1
    Last Post: 06-04-2009, 07:43 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums