It doesn't matter which control has the focus, but it does
require that the current record be the one you want the
report to display.
I can not write the exact code without knowing what you have
on your existing OpenReport statement. In general, all you
need is to add a space and underscore to end of your
existing OpenReport line and put the WhereCondition stuff on
the next line. If the name in the form is different, change
the name after Me. to your name. Replace the member id name
inside the quotes to the name of the field in the report's
record source.
If the member id field in the report is a Text field, then
the additional line should be like:
WhereCondition:= "MemberID=""" & Me.MemberID & """"
If the report;s record source is based on the same table as
the form, then you need to make sure any changes to the
current record are saved to the tabl before opening the
report. Insert this exact line before the OpenReport line:
If Me.Dirty Then Me.Dirty = False
That covers every thing I can guess at. If you have
problems with it, post back with the information I need to.
--
Marsh
MVP [MS Access]
Can you please specify the code exactly how I should write it? Also, will
this work even the MemberID is not on focus?
:
Modify the button's code to use the OpenReport method's
WhereCondition argument:
DoCmd.OpenReport ... , _
WhereCondition:= "MemberID=" & Me.MemberID
Jone wrote:
I have a form and a command button that opens a report, how can I make that
the report should only open for that MemberID that¢s currently open in my
form, for example the MemberID is 376 then the report 376 should open.