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:
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)
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.
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
I did try to find the answer before posting! But if anyone has words of wisdom to add, I'm still listening.
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.