Opening Parameter Query In Code to Display Access Grid

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
 
P

Paul Overway

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top