Filtered Reports

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to be able to click on a button in a form that generates a
report from that specific record I am looking at on the form. I have the form
and report completed. I just don't know how to tell the report that I want it
for the current record only.
 
Hello Pieter, I tried your code, but was not able to get it to work. This is
my current code. It tries, but I get "Syntax errorin date in query expression
'Why - Why # 14178'

DoCmd.OpenReport "Communications Table", acPreview
Reports![Communications Table].Filter = "Why - Why # = " & Me![Why - Why #]
Reports![Communications Table].FilterOn = True

End Sub
--
Thank you for your time!
John


Pieter Wijnen said:
DoCmd.OpenReport ReportName, acViewDesign, WhereCondition := "MyIDField=" &
Me.MyIDField.Value
Or
DoCmd.OpenReport ReportName, acViewDesign, WhereCondition := "MyIDField='" &
Me.MyIDField.Value & "'"

First version for numeric 'MyIDField', seccond for Text

Place the code in The Click_Event [Event Procedure]
Of a CommandButton

HTH

Pieter
 
nasty field name that (presuming [Why - Why #] is a field in the table
it is prefferable not to use special characters (space, -, etc in field
names)
better to use the caption property
Personally I'd rename the field to Why_Why, not in the least since [] are
hard to get to on a norwegian keybord <g>

DoCmd.OpenReport "Communications Table", acPreview, WhereCondition:="[Why -
Why #] = " & Me.[Why - Why #].Value

Pieter


Very Basic User said:
Hello Pieter, I tried your code, but was not able to get it to work. This
is
my current code. It tries, but I get "Syntax errorin date in query
expression
'Why - Why # 14178'

DoCmd.OpenReport "Communications Table", acPreview
Reports![Communications Table].Filter = "Why - Why # = " & Me![Why - Why
#]
Reports![Communications Table].FilterOn = True

End Sub
--
Thank you for your time!
John


Pieter Wijnen said:
DoCmd.OpenReport ReportName, acViewDesign, WhereCondition := "MyIDField="
&
Me.MyIDField.Value
Or
DoCmd.OpenReport ReportName, acViewDesign, WhereCondition :=
"MyIDField='" &
Me.MyIDField.Value & "'"

First version for numeric 'MyIDField', seccond for Text

Place the code in The Click_Event [Event Procedure]
Of a CommandButton

HTH

Pieter


message
I would like to be able to click on a button in a form that generates a
report from that specific record I am looking at on the form. I have
the
form
and report completed. I just don't know how to tell the report that I
want
it
for the current record only.
 
Fantastic, Thank you very much for your help. It worked perfectly.
--
Thank you for your time!
John


Pieter Wijnen said:
nasty field name that (presuming [Why - Why #] is a field in the table
it is prefferable not to use special characters (space, -, etc in field
names)
better to use the caption property
Personally I'd rename the field to Why_Why, not in the least since [] are
hard to get to on a norwegian keybord <g>

DoCmd.OpenReport "Communications Table", acPreview, WhereCondition:="[Why -
Why #] = " & Me.[Why - Why #].Value

Pieter


Very Basic User said:
Hello Pieter, I tried your code, but was not able to get it to work. This
is
my current code. It tries, but I get "Syntax errorin date in query
expression
'Why - Why # 14178'

DoCmd.OpenReport "Communications Table", acPreview
Reports![Communications Table].Filter = "Why - Why # = " & Me![Why - Why
#]
Reports![Communications Table].FilterOn = True

End Sub
--
Thank you for your time!
John


Pieter Wijnen said:
DoCmd.OpenReport ReportName, acViewDesign, WhereCondition := "MyIDField="
&
Me.MyIDField.Value
Or
DoCmd.OpenReport ReportName, acViewDesign, WhereCondition :=
"MyIDField='" &
Me.MyIDField.Value & "'"

First version for numeric 'MyIDField', seccond for Text

Place the code in The Click_Event [Event Procedure]
Of a CommandButton

HTH

Pieter


message
I would like to be able to click on a button in a form that generates a
report from that specific record I am looking at on the form. I have
the
form
and report completed. I just don't know how to tell the report that I
want
it
for the current record only.
 

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

Back
Top