Opening Parameter Query In Code to Display Access Grid

  • Thread starter Thread starter Alok Joshi
  • Start date Start date
A

Alok Joshi

Friends

One of the expert sites gives the following as an example

'************ Code Start ****************
Dim db As Database 'current database
Dim rs As Recordset 'holds query resultset
Dim qdfParmQry As QueryDef 'the actual query object
Set db = CurrentDb()
Set qdfParmQry = db.QueryDefs("Qry1")
qdfParmQry("Please Enter Code:") = 3

' or try this alternate method
' to pass the parameter

qdfParmQry![Please Enter City:] = "New York"
Set rs = qdfParmQry.OpenRecordset()
'************** Code End ***************
However this puts the result of the recordset in rs and then one can go
through the records etc. What I want is just to display the records in a
grid like access does if you run the same query in the GUI. What do I need
to do?ThanksAlok
 
You need to create a form that will allow entry of the parameters needed for
your query, and you can Docmd.OpenQuery "your query". Or create your query
with the required parameters, then Docmd.OpenQuery "your query"....your
query will open and the user will be prompted for the parameters.
 
Back
Top