Report only the linked one

F

Frank Situmorang

Hello,

I have the member's form where is the tab of Note for this member can be
shown up. In this note subform we can make a note with fields like Date,
time, subeject and memo.

How I want to have a command key, to print the report this the hisorical
notes on the particular member which is being shown in this form/subform.

Can anybody help me how can I make it?

Thanks very much.
 
B

BruceM via AccessMonster.com

If I understand your question, you can either make a query that includes both
tables, or you can make a report/subreport just as you made a form/subform,
depending on your needs. To print the report for just the member whose
record you are looking at on the form, use the Where condition of OpenReport:

DoCmd.OpenReport "ReportName", acViewPreview, , _
"[MemberID] = " & Me.MemberID

This assumes there is a field in the Record Source (the table or query on
which the form and report are based) named MemberID, and that it is a Number
field (as set in table design view). If it is a text field:

DoCmd.OpenReport "ReportName", acViewPreview, , _
"[MemberID] = " " " & Me.MemberID & " " " "

or

DoCmd.OpenReport "ReportName", acViewPreview, , _
"[MemberID] = ' " & Me.MemberID & " ' "

You can use the latter if there are no apostrophes in MemberID.

Note that you do not need the exact same Record Source for the form and
report, but they both need to have the MemberID field. For instance, you
could use two different queries.
 
F

Frank Situmorang

Bruce,

I am not expert in Access, so could you please inform me, what is the complete VBA for Where condition?.

Thanks in advance,

Frank



BruceM via AccessMonster.com wrote:

If I understand your question, you can either make a query that includes
29-Dec-09

If I understand your question, you can either make a query that includes bot
tables, or you can make a report/subreport just as you made a form/subform
depending on your needs. To print the report for just the member whos
record you are looking at on the form, use the Where condition of OpenReport

DoCmd.OpenReport "ReportName", acViewPreview, ,
"[MemberID] = " & Me.MemberI

This assumes there is a field in the Record Source (the table or query o
which the form and report are based) named MemberID, and that it is a Numbe
field (as set in table design view). If it is a text field

DoCmd.OpenReport "ReportName", acViewPreview, ,
"[MemberID] = " " " & Me.MemberID & " " "

o

DoCmd.OpenReport "ReportName", acViewPreview, ,
"[MemberID] = ' " & Me.MemberID & " '

You can use the latter if there are no apostrophes in MemberID

Note that you do not need the exact same Record Source for the form an
report, but they both need to have the MemberID field. For instance, yo
could use two different queries

Frank Situmorang wrote

-
Message posted via AccessMonster.co


Previous Posts In This Thread:


Submitted via EggHeadCafe - Software Developer Portal of Choice
Exchange UserCredential between client and webservice in.NET
http://www.eggheadcafe.com/tutorial...f-e3a718f0d96f/exchange-usercredential-b.aspx
 
B

BruceM via AccessMonster.com

I used ReportName, but use the actual name of your report. Same for MemberID
-- use your actual field name.

The code I provided is all you need. The Where condition is just telling
Access to open the report (which already has a Record Source query or table
that includes MemberID), but limit the report to records in which MemberID
matches MemberID on the form. If you are looking at the record of Member 987,
the code is telling Access to open the report, but show records only for
Member 987.

The actual code would probably be in the Click event of a command button, or
something like that. With the form open in design view, click the command
button to select it, then click View >> Properties. Click the Events tab.
Click in the On Click line, then click the three dots on the right. This may
open the VBA editor with the lines:

Private Sub CommandButtonName_Click()

End Sub

and the cursor between those lines. Add the code there.

Upon clicking the three dots you may be presented with a dialog box. If so,
choose Code Builder, then OK. I say "may" because it seems to be behaving
differently than it used to. Maybe there was an update, or maybe I do not
recall correctly, or maybe I made a choice at Tools >> Options or something.
Anyhow, proceed as described when I first described clicking the three dots.

Frank said:
Bruce,

I am not expert in Access, so could you please inform me, what is the complete VBA for Where condition?.

Thanks in advance,

Frank

If I understand your question, you can either make a query that includes
29-Dec-09

If I understand your question, you can either make a query that includes bot
tables, or you can make a report/subreport just as you made a form/subform
depending on your needs. To print the report for just the member whos
record you are looking at on the form, use the Where condition of OpenReport

DoCmd.OpenReport "ReportName", acViewPreview, ,
"[MemberID] = " & Me.MemberI

This assumes there is a field in the Record Source (the table or query o
which the form and report are based) named MemberID, and that it is a Numbe
field (as set in table design view). If it is a text field

DoCmd.OpenReport "ReportName", acViewPreview, ,
"[MemberID] = " " " & Me.MemberID & " " "

o

DoCmd.OpenReport "ReportName", acViewPreview, ,
"[MemberID] = ' " & Me.MemberID & " '

You can use the latter if there are no apostrophes in MemberID

Note that you do not need the exact same Record Source for the form an
report, but they both need to have the MemberID field. For instance, yo
could use two different queries

Frank Situmorang wrote

-
Message posted via AccessMonster.co


Previous Posts In This Thread:

Submitted via EggHeadCafe - Software Developer Portal of Choice
Exchange UserCredential between client and webservice in.NET
http://www.eggheadcafe.com/tutorial...f-e3a718f0d96f/exchange-usercredential-b.aspx
 
F

Frank Situmorang

Bruce,

This is your VBA:
DoCmd.OpenReport "ReportName", acViewPreview, , _


I do not see the where condition here.

Probably you missed it in your 1st reply

Thanks for your sending me again the complete VBA with where condition

Thanks


Frank



BruceM via AccessMonster.com wrote:

I used ReportName, but use the actual name of your report.
29-Dec-09

I used ReportName, but use the actual name of your report. Same for MemberI
-- use your actual field name

The code I provided is all you need. The Where condition is just tellin
Access to open the report (which already has a Record Source query or tabl
that includes MemberID), but limit the report to records in which MemberI
matches MemberID on the form. If you are looking at the record of Member 987
the code is telling Access to open the report, but show records only fo
Member 987

The actual code would probably be in the Click event of a command button, o
something like that. With the form open in design view, click the comman
button to select it, then click View >> Properties. Click the Events tab
Click in the On Click line, then click the three dots on the right. This ma
open the VBA editor with the lines

Private Sub CommandButtonName_Click(

End Su

and the cursor between those lines. Add the code there

Upon clicking the three dots you may be presented with a dialog box. If so
choose Code Builder, then OK. I say "may" because it seems to be behavin
differently than it used to. Maybe there was an update, or maybe I do no
recall correctly, or maybe I made a choice at Tools >> Options or something
Anyhow, proceed as described when I first described clicking the three dots

Frank Situmorang wrote

-
Message posted via AccessMonster.co


Previous Posts In This Thread:


Submitted via EggHeadCafe - Software Developer Portal of Choice
Build A Self-Caching ASP.NET Web Site Thumbnail Control
http://www.eggheadcafe.com/tutorial...571-cdc4eb38f3c1/build-a-selfcaching-asp.aspx
 
B

BruceM via AccessMonster.com

Please review the posting in which I first showed the code. It should look
like this:

DoCmd.OpenReport "ReportName", acViewPreview, , _
"[MemberID] = " & Me.MemberID

There should be two lines in the newsreader, but there is just one line of
code. The underscore (preceded by a space) is a VBA line continuation
character. It was intended to avoid wrapping in the newsreader. It also can
make the code easier to read. You could do this:

DoCmd.OpenReport "ReportName", acViewPreview, , "[MemberID] = " & Me.MemberID

Note that it is one line of code. If it wraps in the newsreader, place it all
 

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