Opening a form based on a parameterized query without parms dialog displayed?

  • Thread starter Savvoulidis Iordanis
  • Start date
S

Savvoulidis Iordanis

Hello access users.
The problem I am having is about opening a form, in which,
the form's recordsource is a query with parameters (Query | Parameters...)
How can I avoid the small window opening when the form is about to open
(VERY UGLY)?
The parameters for the form to open are passed using the .OpenArgs property.
Is there any way to avoid that, using code like the following ( which
produces an error for me...)
(and assuming that the form's record source is not set at the beginning,
because
if it does, the query is trying to execute immediatelly)

Private Sub Form_Load()
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim rs As DAO.Recordset
Dim fld As DAO.Field

Set dbs = CurrentDb ' WORKS
Set qdf = dbs.QueryDefs("qry1") ' WORKS
qdf.Parameters("id_parm").Value = Nz(Me.OpenArgs, "") ' WORKS
Set rs = qdf.OpenRecordset(dbOpenForwardOnly) ' WORKS and has results

' ERROR HERE when trying to pass the recordset object to the form's
recordset
' although there is an example line in the Access Help that does that
' Set Me.Recordset = rs
''''''''''''''''''''

''''''''''''''''''''''''''''''''''''''''''''
' NOW, THIS IS another way I tried to set the values to the fields
' but they should not have the control source property set in the
properties window
' which does solve the problem, but, the form is now not bound to DB

For Each fld In rs.Fields
Me(fld.Name) = fld.Value
Next

End Sub

HEEEELP!
 

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