Wednesday, October 04, 2006

Passing parameters from form to query

I didn't use this idea for my website, but I think it is a very usefull tip voor the MS Access developers among us.
This solution passes values from a MS Access form to a query without defining parameters in de query.

Create an global array:
Global Params(10)

Create a function that returns a value from
Function RtnParams(ParamNum As Integer)
ReturnParam = Para=ms(ParamNum)
End Function


Somewhere in the form (click event button for example) store the values into the array

Params(1) = txtId (from field)

Call in the WHERE-clause of the query the function which returns the right value:
Select * FROM table
WHERE id = ReturnParams(1)


Simple and effective, yet again.

No comments: