Let's take an example. the parameterized query looks like that:
Select Tbl_Country.* From Tbl_Country WHERE id_Country = _
[?enter ISO code of the country]
and you'd like to be able to get this value (the [?enter ... country] one) from a form, where you have your controls and some data in it. Well... this might be possible, but it requires some code normalisation.
One solution would be to have your form controls named after a certain logic, such as fid_Country
for the control that will hold an id_Country
value. Your can then have your query as a string:
qr = "Select Tbl_Country.* From Tbl_Country WHERE id_Country = [fid_country]"
Once you have entered all requested data in your form, press your "query" button. The logic will browse all controls and check if they are in the query, eventually replacing the parameter by the control's value:
Dim ctl as Control
For each ctl in Me.controls
If instr(qr,"[" & ctl.name & "]") > 0 Then
qr = replace(qr,"[" & ctl.name & "]",ctl.value)
End if
Next i
Doing so, you will have a fully updated query, where parameters have been replaced by real data. Depending on the type of fid_country (string, GUID, date, etc), you could have to add some extra double quotes or not, to get a final query such as:
qr = "Select Tbl_Country.* From Tbl_Country WHERE id_Country = ""GB"""
Which is a fully Access compatible query you can use to open a recordset:
Set rsQuery = currentDb.openRecordset(qr)
I think you are done here.
This subject is critical when your objective is to developp Access applications. You have to offer users a standard way to query data from their GUI, not only to launch queries, but also to filter continuous forms (just in the way Excel do it with its "autofilter" option) and manage reports parameters. Good luck!