Displaying Query Ealue that requires an input parameter

A

Access::Student

I have a query that returns a single aggregate value based on the input
parameter. I can't figure out how to display this on a form. The parameter I
want to pass to the query is the primary key from the current record. Any
ides?
 
T

TonyN

Access::Student said:
I have a query that returns a single aggregate value based on the input
parameter. I can't figure out how to display this on a form. The parameter I
want to pass to the query is the primary key from the current record. Any
ides?

Would this work for you? Basically, construct the SQL Query in your code and
then run it to create a new RecordSet - something like this:

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String

Set db = CurrentDb

strSQL = "SELECT etc. . ." & [PrimaryKey] & ". . . more SQL code, as required"

Set rs = db.OpenRecordset(strSQL)

MsgBox "Returned Value: " & rs!FieldName

rs.Close
db.Close

If the Primary Key value is a field on your form, you might be able to pass
it to an already defined Query as a Forms! reference.

I hope this helps. . .

Tony N
 

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