Translating values from a form into a JET query

O

Ogelema

Dear all,

I am looking for some assistance with getting some information from a form
into a query that goes directly to JET. Presently I am having the error “too
few parametersâ€, when I try to input the values using the
Forms!FormName!FieldName format. Is there any way I could do this?

I do not want to run an Access query, which would recognise the GUI, as the
query is dynamic, in the sense that the criteria are built based on the
values of fields on the form, which are entered by the user.

I will be looking forward to your assistance.

Yours,

Ogelema
 
M

Michel Walsh

Hi,


The User Interface and DoCmd recognize the syntax
Forms!FormName!ControlName, but CurrentDb does not. In the last case, you
have to fill the parameters collection:


DIm db As Database : Set db=CurrentDb
Dim qdf As QueryDef : Set qdf=db.QueryDefs("queryName")
Dim param As DAO.Parameter

For each param in qdf.Paramaters
param.value = eval( param.name )
Next param

' ... do something with qdf
Dim rst As DAO.Recorset
Set rst=qdf.OpenRecordset( ... )





Hoping it may help,
Vanderghast, Access MVP
 
O

Ogelema

Hello Michel,

Thank you very much for your assistance.

I got it working using the RunSQL method of the DoCmd object, which accepted
the Access GUI format.

Once again thank you.

Yours,

Ogelema
 
Top