More on selecting records on a sub form -

  • Thread starter Thread starter Abay
  • Start date Start date
A

Abay

I think my question should have been .. how do I pass a parameter from a
form through a macro to a query .. i.e. what I want to do is to select all
transactions for the Client whose data is on the sub form, using the
Client's LastName as the selection criteria ..

abay
 
Abay,

This is not a job for a macro. And a query can't get data from a form.
The good news is that it actually simpler than that. All you need to
do is make a query based on your table, and in the Criteria of the
LastName field, put the equivalent of this...
[Forms]![NameOfYourForm]![LastName]
 
Sorry, Steve, you are only partially correct. The correct parts are that it
should not be a macro. If the action of the macro is needed, convert it to
code and put it where the macro is called. Your statement that a query can't
get data from a form is correct, but the best way to do it is like this:

Put something like this in the click event of the command button:

Set qdf = CurrentDb.QueryDefs("qselSCCBhdr")
qdf.Parameters(0) = Me.cboResource
qdf.Parameters(1) = Me.cboPeriod
Set rstItms = qdf.OpenRecordset(dbOpenSnapshot, dbReadOnly)


Steve Schapel said:
Abay,

This is not a job for a macro. And a query can't get data from a form.
The good news is that it actually simpler than that. All you need to
do is make a query based on your table, and in the Criteria of the
LastName field, put the equivalent of this...
[Forms]![NameOfYourForm]![LastName]

--
Steve Schapel, Microsoft Access MVP

I think my question should have been .. how do I pass a parameter from a
form through a macro to a query .. i.e. what I want to do is to select all
transactions for the Client whose data is on the sub form, using the
Client's LastName as the selection criteria ..

abay
 
Many thanks to all for your suggestions .. will try them out ..

abay

Steve Schapel said:
Abay,

This is not a job for a macro. And a query can't get data from a form.
The good news is that it actually simpler than that. All you need to
do is make a query based on your table, and in the Criteria of the
LastName field, put the equivalent of this...
[Forms]![NameOfYourForm]![LastName]

--
Steve Schapel, Microsoft Access MVP

I think my question should have been .. how do I pass a parameter from a
form through a macro to a query .. i.e. what I want to do is to select all
transactions for the Client whose data is on the sub form, using the
Client's LastName as the selection criteria ..

abay
 
Back
Top