If I understand correctly, QueryDefs are not necessary and the RunSQL
method/action only uses action queries. You wnat a SELECT query applied to a
forms recordsource. I find it helpfull (sometimes faster) to build the query
in design view, then switch to SQLview and then copy and paste the string to
the module I'm working in. Then I mdify the string to suit, adding variables
and other critertia. You usage way look something like this. (You'll
probably have to change a few things to do everything you want it to do)
Dim sqlStr As String
Dim strStation As String
sqlStr = "SELECT tblproblem.StationName, << other fields >> FROM tblproblem
sqlStr = sqlStr & "WHERE (tblproblem.StationName = '" & strStation & "');"
'note the single quotes before and after the double quotes
'assign strStationName with the computer being clicked on prior to this
section
DoCmd.OpenForm "<<frmName>>"
Forms("<<frmName>>").RecordSource = sqlStr
Forms("<<frmName>>").Refresh
This could also be accomplished using a filter on the opening form, but I
personally don't like using them.
Mike Storr
www.veraccess.com
"Simon Bailey" <go*********@hotmail.com> wrote in message
news:1c**************************@posting.google.c om...
I am attempting to implement a fault logging database in Access.
My idea is to have a form with lots of buttons on it. Each button will
represent a computer in a certain room. When i click on the button I
want the fault history of this computer displayed as a form. So
basically i would want a query based on my table to search for a
computer, say workstation "H7-11" to be activated from an 'on click'
property.
My tbl is tblproblem. And the field i want to seach from is
StationName. The database i am working on is project.mdb.
I dont understand all this stuff about QueryDef and RunSQL (pardon my
ignorance but Microsoft Access help isnt my best friend!!) :)
Could somebody in the know please try and give me some code to work
on?
Many Thanks.