Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2006
    Posts
    111

    Unanswered: I just want a row back from my select query!

    I've been working with sql server and vb.net for so long that I've forgotten Access (if indeed I ever really knew it...)

    I want to run a select query, get a row back, examine boolean columns and either enable or disabled fields on a form accordingly.

    So far I have this:
    Code:
    Dim dbs As Database, qdf As QueryDef, strSQL As String
    Set dbs = CurrentDb
    strSQL = "SELECT * FROM PrintingInformation WHERE ID =" _
        & "'" & Forms![Label Information Form]![ID] & "';"
    Set qdf = dbs.CreateQueryDef("GetPrintInfoForID", strSQL)
    qdf.Execute
    But what do I need to have access to the row so I can process it?

    In addition to answering the question, can you recommend documentation? I'm sure I'll have many more questions and would like to help myself and not bother you guys for the week or two I'm working on this project.

    Thanks.

  2. #2
    Join Date
    Jul 2006
    Posts
    111
    I think I've got it:

    Code:
    Dim MyDB As DAO.Database, MyRec As DAO.Recordset, MyList As String
    Set MyDB = CurrentDb
    Set MyRec = MyDB.OpenRecordset("Select * From PrintingInformation WHERE ID = 6")
    While Not MyRec.EOF  ' Loop trough the table
        MsgBox (MyRec![PrintFieldA])
        MyRec.MoveNext
    Wend
    I did try to find the answer before posting! But if anyone has words of wisdom to add, I'm still listening.

  3. #3
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    I still don't understand the question.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Your basic problem in the first post is that the Execute method can only be used for action queries. It does not return records. Your second post uses a recordset, which would be a common way of getting a value from a query. You could also have used a DLookup, if only one value would be returned.
    Paul

  5. #5
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Ah. "row back" threw me ^^
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  6. #6
    Join Date
    Jul 2006
    Posts
    111
    Quote Originally Posted by StarTrekker
    Ah. "row back" threw me ^^
    Oh...would "row returned" have been better???

    Thanks, pbaldy, for the explanation of the first way not giving me a row back (oops, I mean "returning me a row" ).

    Thanks all.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •