
Help! Parameter Query via Data Control
I don't have any problem of opening a parameter query in Access 1.0
using a snapshot or a dynaset. But I could not figure out how to open a
parameter query using the data control. My parameter query is a query
that was saved previously in Access and it expects a parameter.
It works great if I do it using the snapshot:
Set MyDB = OpenDatabase("c:\data\mydb.mdb", False, True)
Set MyQuery = MyDB.OpenQueryDef("get_name") ' query name
MyQuery![PED CODE] = "NY" ' parameter
Set MySnap = MyQuery.CreateSnapshot()
While Not MySnap.EOF
....
So I tried the same thing using the data control but it never works:
Data1.DatabaseName = "c:\data\mydb.mdb"
Data1.RecordSource = "get_name" ' my query name
Data1.Filter = "[PED CODE] = " & PEDCODE ' parameter
Data1.Refresh
Data1.recordset.movefirst
While Not Data1.recordset.EOF
...
This one goes into infinite loop. It never reaches the EOF mark.
Question:
Can I be able to open a parameter query using the data control and pass a
parameter to it? If yes, please show me how.
Any other help would be appreciated.