Opn Rpt for THIS record

B

Bonnie

Hi everyone!!! Happy Cinco de Mayo! Using A02 on XP. Have
a form with unique field [Key]. Want to fill in the form
and click the button to open the report. But only want the
report for that record not all records and don't want to
use a parameter that requires you to type again. I have
the following but a parameter box appears and the wordage
is actually the field value. If I type it in again, the
report opens with just the one record but, again, I've had
to type the unique field. What is wrong with my wordage?

DoCmd.OpenReport "rSAR", acViewPreview, , "[Key]=" & Me.Key
DoCmd.RunCommand acCmdZoom100

Thanks in advance for any help or advice! LUV U GUYS!
 
G

Guest

You could just open it up as normal with a 'where' statement in the report
record source i.e. where it equals the form record ID or 'KEY'
Thanks
 
R

Rick B

Do you have a field on your form called "Key"?

--
Rick B



sam said:
You could just open it up as normal with a 'where' statement in the report
record source i.e. where it equals the form record ID or 'KEY'
Thanks


Bonnie said:
Hi everyone!!! Happy Cinco de Mayo! Using A02 on XP. Have
a form with unique field [Key]. Want to fill in the form
and click the button to open the report. But only want the
report for that record not all records and don't want to
use a parameter that requires you to type again. I have
the following but a parameter box appears and the wordage
is actually the field value. If I type it in again, the
report opens with just the one record but, again, I've had
to type the unique field. What is wrong with my wordage?

DoCmd.OpenReport "rSAR", acViewPreview, , "[Key]=" & Me.Key
DoCmd.RunCommand acCmdZoom100

Thanks in advance for any help or advice! LUV U GUYS!
 
B

Bonnie

Yes I do. It is in my query, form and report (visible=no)
-----Original Message-----
Do you have a field on your form called "Key"?

--
Rick B



sam said:
You could just open it up as normal with a 'where' statement in the report
record source i.e. where it equals the form record ID or 'KEY'
Thanks


Bonnie said:
Hi everyone!!! Happy Cinco de Mayo! Using A02 on XP. Have
a form with unique field [Key]. Want to fill in the form
and click the button to open the report. But only want the
report for that record not all records and don't want to
use a parameter that requires you to type again. I have
the following but a parameter box appears and the wordage
is actually the field value. If I type it in again, the
report opens with just the one record but, again, I've had
to type the unique field. What is wrong with my wordage?

DoCmd.OpenReport "rSAR", acViewPreview, , "[Key]=" & Me.Key
DoCmd.RunCommand acCmdZoom100

Thanks in advance for any help or advice! LUV U GUYS!


.
 
B

Bonnie

Don't know how to do that.
-----Original Message-----
You could just open it up as normal with a 'where' statement in the report
record source i.e. where it equals the form record ID or 'KEY'
Thanks


Bonnie said:
Hi everyone!!! Happy Cinco de Mayo! Using A02 on XP. Have
a form with unique field [Key]. Want to fill in the form
and click the button to open the report. But only want the
report for that record not all records and don't want to
use a parameter that requires you to type again. I have
the following but a parameter box appears and the wordage
is actually the field value. If I type it in again, the
report opens with just the one record but, again, I've had
to type the unique field. What is wrong with my wordage?

DoCmd.OpenReport "rSAR", acViewPreview, , "[Key]=" & Me.Key
DoCmd.RunCommand acCmdZoom100

Thanks in advance for any help or advice! LUV U GUYS!
.
 
G

Guest

Easiest way to do this is in the Open event of your report:

me.filter = forms!MyForm.Key
me.filteron = true

Bonnie said:
Don't know how to do that.
-----Original Message-----
You could just open it up as normal with a 'where' statement in the report
record source i.e. where it equals the form record ID or 'KEY'
Thanks


Bonnie said:
Hi everyone!!! Happy Cinco de Mayo! Using A02 on XP. Have
a form with unique field [Key]. Want to fill in the form
and click the button to open the report. But only want the
report for that record not all records and don't want to
use a parameter that requires you to type again. I have
the following but a parameter box appears and the wordage
is actually the field value. If I type it in again, the
report opens with just the one record but, again, I've had
to type the unique field. What is wrong with my wordage?

DoCmd.OpenReport "rSAR", acViewPreview, , "[Key]=" & Me.Key
DoCmd.RunCommand acCmdZoom100

Thanks in advance for any help or advice! LUV U GUYS!
.
 
G

Guest

I put the following in my OnOpen event:

Forms![fSARMain]![fSAR].Form![Key]

I created a button to open the report. OnClick I get a parameter box and
the wordage is the data in the field [Key]. If I click through, I get errors
on the report. If I enter the data (00020205), I get the report but with ALL
records.

I know I must have something stupid somewhere that is hanging me up but
can't figure out what it is. Any ideas would be helpful. Thanks in advance
for any help!
--
Bonnie


Klatuu said:
Easiest way to do this is in the Open event of your report:

me.filter = forms!MyForm.Key
me.filteron = true

Bonnie said:
Don't know how to do that.
-----Original Message-----
You could just open it up as normal with a 'where' statement in the report
record source i.e. where it equals the form record ID or 'KEY'
Thanks


:

Hi everyone!!! Happy Cinco de Mayo! Using A02 on XP. Have
a form with unique field [Key]. Want to fill in the form
and click the button to open the report. But only want the
report for that record not all records and don't want to
use a parameter that requires you to type again. I have
the following but a parameter box appears and the wordage
is actually the field value. If I type it in again, the
report opens with just the one record but, again, I've had
to type the unique field. What is wrong with my wordage?

DoCmd.OpenReport "rSAR", acViewPreview, , "[Key]=" & Me.Key
DoCmd.RunCommand acCmdZoom100

Thanks in advance for any help or advice! LUV U GUYS!


.
 
G

Guest

I think your syntax is incorrect. I guess I don't quit understand this line:
Forms![fSARMain]![fSAR].Form![Key]

What is should be is:
Forms![Name of Form]![Name of Control]

The rest I don't get.
I also did not see the me.filter or me.filteron properties being set. Try
again with

This should go in the On Open event of the Report

me.filter = "Name of Record Source Field to Filter = '" & forms![Name Of
Form Opening the Reprt]![Name of Control with Key Value] & "'"
me.filteron = true

Bonnie said:
I put the following in my OnOpen event:

Forms![fSARMain]![fSAR].Form![Key]

I created a button to open the report. OnClick I get a parameter box and
the wordage is the data in the field [Key]. If I click through, I get errors
on the report. If I enter the data (00020205), I get the report but with ALL
records.

I know I must have something stupid somewhere that is hanging me up but
can't figure out what it is. Any ideas would be helpful. Thanks in advance
for any help!
--
Bonnie


Klatuu said:
Easiest way to do this is in the Open event of your report:

me.filter = forms!MyForm.Key
me.filteron = true

Bonnie said:
Don't know how to do that.

-----Original Message-----
You could just open it up as normal with a 'where'
statement in the report
record source i.e. where it equals the form record ID
or 'KEY'
Thanks


:

Hi everyone!!! Happy Cinco de Mayo! Using A02 on XP.
Have
a form with unique field [Key]. Want to fill in the
form
and click the button to open the report. But only want
the
report for that record not all records and don't want
to
use a parameter that requires you to type again. I have
the following but a parameter box appears and the
wordage
is actually the field value. If I type it in again, the
report opens with just the one record but, again, I've
had
to type the unique field. What is wrong with my wordage?

DoCmd.OpenReport "rSAR", acViewPreview, , "[Key]=" &
Me.Key
DoCmd.RunCommand acCmdZoom100

Thanks in advance for any help or advice! LUV U GUYS!


.
 
G

Guest

Sorry, I only posted the error line. In the OnOpen Event I have:

Private Sub Report_Open(Cancel As Integer)
Me.Filter = Forms![fSARMain]![fSAR].Form![Key]
Me.FilterOn = True
End Sub

(fSAR is a subform)

On the subform, the field on the record I want reads: 00022005

With the form open to the record I want, I open the report and receive a
dialog box titled "Enter Parameter Value" and where it would normally say,
"what key?", it reads "00022005". If I type 00022005 into the parameter
inquiry, the report opens with all records. UGGGHHH! Can't figure out what
I'm doing wrong!

Thanks VERY much for trying to help, I'll cross my fingers...
 
G

Guest

One more time, the Me.Filter = has to have the name of the field in the
record source to compare against. It also has to be formatted like a WHERE
clause. That is what is basically is.

Bonnie said:
Sorry, I only posted the error line. In the OnOpen Event I have:

Private Sub Report_Open(Cancel As Integer)
Me.Filter = "FIELD NAME WITH VALUE TO FILTER ON = '" & Forms![fSARMain]![fSAR].Form![Key] & "'"
Me.FilterOn = True
End Sub

(fSAR is a subform)

On the subform, the field on the record I want reads: 00022005

With the form open to the record I want, I open the report and receive a
dialog box titled "Enter Parameter Value" and where it would normally say,
"what key?", it reads "00022005". If I type 00022005 into the parameter
inquiry, the report opens with all records. UGGGHHH! Can't figure out what
I'm doing wrong!

Thanks VERY much for trying to help, I'll cross my fingers...
--
Bonnie


Klatuu said:
I think your syntax is incorrect. I guess I don't quit understand this line:
Forms![fSARMain]![fSAR].Form![Key]

What is should be is:
Forms![Name of Form]![Name of Control]

The rest I don't get.
I also did not see the me.filter or me.filteron properties being set. Try
again with

This should go in the On Open event of the Report

me.filter = "Name of Record Source Field to Filter = '" & forms![Name Of
Form Opening the Reprt]![Name of Control with Key Value] & "'"
me.filteron = true
 
R

Rick B

Bonnie:

Keep in mind that if you filter the report rather than applying the filter
in your button, you will not be able to run that report without your form
open and the filter applied.

Personally, I never do this. I want the option to run the report with all
records in most cases and also to run just a single record.

It all depends on what you are using it for, but following the steps
outlined to apply the filter in the report design will not let you run it
and get all records.

Also, if you go down that road, I would put some code in there to make sure
the needed form is open before you go any further. If it is not, I would
display some meaningful error message.

--
Rick B



Bonnie said:
Sorry, I only posted the error line. In the OnOpen Event I have:

Private Sub Report_Open(Cancel As Integer)
Me.Filter = Forms![fSARMain]![fSAR].Form![Key]
Me.FilterOn = True
End Sub

(fSAR is a subform)

On the subform, the field on the record I want reads: 00022005

With the form open to the record I want, I open the report and receive a
dialog box titled "Enter Parameter Value" and where it would normally say,
"what key?", it reads "00022005". If I type 00022005 into the parameter
inquiry, the report opens with all records. UGGGHHH! Can't figure out what
I'm doing wrong!

Thanks VERY much for trying to help, I'll cross my fingers...
--
Bonnie


Klatuu said:
I think your syntax is incorrect. I guess I don't quit understand this line:
Forms![fSARMain]![fSAR].Form![Key]

What is should be is:
Forms![Name of Form]![Name of Control]

The rest I don't get.
I also did not see the me.filter or me.filteron properties being set. Try
again with

This should go in the On Open event of the Report

me.filter = "Name of Record Source Field to Filter = '" & forms![Name Of
Form Opening the Reprt]![Name of Control with Key Value] & "'"
me.filteron = true
 
G

Guest

If you allow users direct access to your reports, then what you say is good
practice. I never allow users direct access to anything. Sooner or later,
someone will screw up your database and it will be your fault.

Rick B said:
Bonnie:

Keep in mind that if you filter the report rather than applying the filter
in your button, you will not be able to run that report without your form
open and the filter applied.

Personally, I never do this. I want the option to run the report with all
records in most cases and also to run just a single record.

It all depends on what you are using it for, but following the steps
outlined to apply the filter in the report design will not let you run it
and get all records.

Also, if you go down that road, I would put some code in there to make sure
the needed form is open before you go any further. If it is not, I would
display some meaningful error message.

--
Rick B



Bonnie said:
Sorry, I only posted the error line. In the OnOpen Event I have:

Private Sub Report_Open(Cancel As Integer)
Me.Filter = Forms![fSARMain]![fSAR].Form![Key]
Me.FilterOn = True
End Sub

(fSAR is a subform)

On the subform, the field on the record I want reads: 00022005

With the form open to the record I want, I open the report and receive a
dialog box titled "Enter Parameter Value" and where it would normally say,
"what key?", it reads "00022005". If I type 00022005 into the parameter
inquiry, the report opens with all records. UGGGHHH! Can't figure out what
I'm doing wrong!

Thanks VERY much for trying to help, I'll cross my fingers...
--
Bonnie


Klatuu said:
I think your syntax is incorrect. I guess I don't quit understand this line:
Forms![fSARMain]![fSAR].Form![Key]

What is should be is:
Forms![Name of Form]![Name of Control]

The rest I don't get.
I also did not see the me.filter or me.filteron properties being set. Try
again with

This should go in the On Open event of the Report

me.filter = "Name of Record Source Field to Filter = '" & forms![Name Of
Form Opening the Reprt]![Name of Control with Key Value] & "'"
me.filteron = true
 
R

Rick Brandt

Klatuu said:
If you allow users direct access to your reports, then what you say
is good practice. I never allow users direct access to anything.
Sooner or later, someone will screw up your database and it will be
your fault.

Sometimes wanting to open a report with no filter at all is not the same as
"allowing users direct access to your reports". What if you want to open
the report sometimes from one form and sometimes from some other form?

Looking for a specific form in the Open event locks you into running the
report only when that particular form is open unless you put a bunch of
IsLoaded() tests into the event. It's just not necessary in most cases.
 
G

Guest

In my early post I stated that my whole purpose here is that I have a form
that will be opened, a record created, validated and saved, then printed.

I just can't figure out why the filter isn't working. Any ideas on that
issue?
--
Bonnie


Rick B said:
Bonnie:

Keep in mind that if you filter the report rather than applying the filter
in your button, you will not be able to run that report without your form
open and the filter applied.

Personally, I never do this. I want the option to run the report with all
records in most cases and also to run just a single record.

It all depends on what you are using it for, but following the steps
outlined to apply the filter in the report design will not let you run it
and get all records.

Also, if you go down that road, I would put some code in there to make sure
the needed form is open before you go any further. If it is not, I would
display some meaningful error message.

--
Rick B



Bonnie said:
Sorry, I only posted the error line. In the OnOpen Event I have:

Private Sub Report_Open(Cancel As Integer)
Me.Filter = Forms![fSARMain]![fSAR].Form![Key]
Me.FilterOn = True
End Sub

(fSAR is a subform)

On the subform, the field on the record I want reads: 00022005

With the form open to the record I want, I open the report and receive a
dialog box titled "Enter Parameter Value" and where it would normally say,
"what key?", it reads "00022005". If I type 00022005 into the parameter
inquiry, the report opens with all records. UGGGHHH! Can't figure out what
I'm doing wrong!

Thanks VERY much for trying to help, I'll cross my fingers...
--
Bonnie


Klatuu said:
I think your syntax is incorrect. I guess I don't quit understand this line:
Forms![fSARMain]![fSAR].Form![Key]

What is should be is:
Forms![Name of Form]![Name of Control]

The rest I don't get.
I also did not see the me.filter or me.filteron properties being set. Try
again with

This should go in the On Open event of the Report

me.filter = "Name of Record Source Field to Filter = '" & forms![Name Of
Form Opening the Reprt]![Name of Control with Key Value] & "'"
me.filteron = true
 
G

Guest

So what if both of the forms were loaded? You could always apply the filter
with the Openreport
 
R

Rick Brandt

Klatuu said:
So what if both of the forms were loaded? You could always apply the
filter with the Openreport

I don't understand this statement. The point that Rick B was making (and
that I was agreeing with) was that having the following in the Open event of
a report...

Private Sub Report_Open(Cancel As Integer)
Me.Filter = Forms![fSARMain]![fSAR].Form![Key]
Me.FilterOn = True
End Sub

....means that this report can now never be used unless the Form fSARMain is
opened. Since the same filter can be dynamically applied by using the WHERE
argument of the OpenReport method there is simply no reason to apply the
filter in the Open event unless you need it to apply to a report being
Emailed or written to disk where you don't have the benefit of dynamic WHERE
clause.
 

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