Use Filter To Print This Record Only

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

Guest

Hi everyone, using A02 on XP. Not a programmer but trying to get there. I
have a form (with a subform). On the subform a record is created, edited,
macro validated and saved. Have a btn to preview report. Have the following
in the OnOpen event of the report:

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

(I got the wordage: Forms![fSARMain]![fSAR].Form![Key] with the expression
builder. [Key] is the unique ID field on the subform.)

(fSAR is a subform)

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

With the form open to that record, I click the preview report btn and
receive a
dialog box titled "Enter Parameter Value" and where it would normally say
what I want like "what key?", instead it reads "00022005". If I type 00022005
into the parameter inquiry, the report opens with all records. Press enter on
the blank and get the ol' fav ERROR in all fields. UGGGHHH! Can't figure out
what I'm doing wrong!

I would appreciate any help or advice. Thanks in advance!
 
I was becoming confused and felt a bit of attitude in your replies. My
purpose was to repost and try to communicate with someone else.

Your final post to me in the prior thread read:

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.

I understand that. My line contained the name of the field. The field
exists on a subform. It appears I have done what you said and it still gives
me the same parameter problem.

Please remember, I am not a skilled professional programmer. I am learning
VB but much of it seems illogical until placed in a context I can relate to.

If you care to continue, feel free but please come down to my level. Thank
you for participating in the newsgroups and trying to help.
--
Bonnie


Klatuu said:
Bonnie, I think I answered this post already in reports. Is it still not
working?

Bonnie said:
Hi everyone, using A02 on XP. Not a programmer but trying to get there. I
have a form (with a subform). On the subform a record is created, edited,
macro validated and saved. Have a btn to preview report. Have the following
in the OnOpen event of the report:

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

(I got the wordage: Forms![fSARMain]![fSAR].Form![Key] with the expression
builder. [Key] is the unique ID field on the subform.)

(fSAR is a subform)

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

With the form open to that record, I click the preview report btn and
receive a
dialog box titled "Enter Parameter Value" and where it would normally say
what I want like "what key?", instead it reads "00022005". If I type 00022005
into the parameter inquiry, the report opens with all records. Press enter on
the blank and get the ol' fav ERROR in all fields. UGGGHHH! Can't figure out
what I'm doing wrong!

I would appreciate any help or advice. Thanks in advance!
 
Sorry, Bonnie, did not mean to offend. I understand your frustration and I
am happy to try to help.
What you sent me is not correct, yet. Try looking in Acces Help for the
Filter Property. To correctly set a filter, it has to be Table Field Name =
Value To Filter On
Here is a cut and paste from Help:

Me.Filter = "Country = 'USA'"
Me.FilterOn = True

In the above case, Country is the name of the field in the table and USA is
the value to filter on.

That is why it is not working is that there is no comparison value here.
Also note the compare vaule needs to be in single quotes.
I don't know what the table field name is, but for this lets call it MyField

Your current code:
Me.Filter = Forms![fSARMain]![fSAR].Form![Key]
Me.FilterOn = True

I am assuming that Forms![fSARMain]![fSAR].Form![Key] is the control on your
form that contains the value you want to filter on. If so, then change your
code to:
Me.Filter = "MyField = '" & Forms![fSARMain]![fSAR].Form![Key] & "'"
Me.FilterOn = True

Again, I apologize for my comment. I did not mean for it to be as rude as
it looks.

Bonnie said:
I was becoming confused and felt a bit of attitude in your replies. My
purpose was to repost and try to communicate with someone else.

Your final post to me in the prior thread read:

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.

I understand that. My line contained the name of the field. The field
exists on a subform. It appears I have done what you said and it still gives
me the same parameter problem.

Please remember, I am not a skilled professional programmer. I am learning
VB but much of it seems illogical until placed in a context I can relate to.

If you care to continue, feel free but please come down to my level. Thank
you for participating in the newsgroups and trying to help.
--
Bonnie


Klatuu said:
Bonnie, I think I answered this post already in reports. Is it still not
working?

Bonnie said:
Hi everyone, using A02 on XP. Not a programmer but trying to get there. I
have a form (with a subform). On the subform a record is created, edited,
macro validated and saved. Have a btn to preview report. Have the following
in the OnOpen event of the report:

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

(I got the wordage: Forms![fSARMain]![fSAR].Form![Key] with the expression
builder. [Key] is the unique ID field on the subform.)

(fSAR is a subform)

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

With the form open to that record, I click the preview report btn and
receive a
dialog box titled "Enter Parameter Value" and where it would normally say
what I want like "what key?", instead it reads "00022005". If I type 00022005
into the parameter inquiry, the report opens with all records. Press enter on
the blank and get the ol' fav ERROR in all fields. UGGGHHH! Can't figure out
what I'm doing wrong!

I would appreciate any help or advice. Thanks in advance!
 
Thank you VERY much for the clarification. I did have to make one additional
alteration to your filter line:
Yours:
Me.Filter = "MyField = '" & Forms![fSARMain]![fSAR].Form![Key] & "'"
Mine:
Me.Filter = "[Key] = '" & Forms![fSARMain]![fSAR].Form![Key] & "'"

I had to change MyField to [Key]. It works now.

Thanks for sticking with this thread. It's the quotes that mess me up.
--
Bonnie


Klatuu said:
Sorry, Bonnie, did not mean to offend. I understand your frustration and I
am happy to try to help.
What you sent me is not correct, yet. Try looking in Acces Help for the
Filter Property. To correctly set a filter, it has to be Table Field Name =
Value To Filter On
Here is a cut and paste from Help:

Me.Filter = "Country = 'USA'"
Me.FilterOn = True

In the above case, Country is the name of the field in the table and USA is
the value to filter on.

That is why it is not working is that there is no comparison value here.
Also note the compare vaule needs to be in single quotes.
I don't know what the table field name is, but for this lets call it MyField

Your current code:
Me.Filter = Forms![fSARMain]![fSAR].Form![Key]
Me.FilterOn = True

I am assuming that Forms![fSARMain]![fSAR].Form![Key] is the control on your
form that contains the value you want to filter on. If so, then change your
code to:
Me.Filter = "MyField = '" & Forms![fSARMain]![fSAR].Form![Key] & "'"
Me.FilterOn = True

Again, I apologize for my comment. I did not mean for it to be as rude as
it looks.

Bonnie said:
I was becoming confused and felt a bit of attitude in your replies. My
purpose was to repost and try to communicate with someone else.

Your final post to me in the prior thread read:

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.

I understand that. My line contained the name of the field. The field
exists on a subform. It appears I have done what you said and it still gives
me the same parameter problem.

Please remember, I am not a skilled professional programmer. I am learning
VB but much of it seems illogical until placed in a context I can relate to.

If you care to continue, feel free but please come down to my level. Thank
you for participating in the newsgroups and trying to help.
--
Bonnie


Klatuu said:
Bonnie, I think I answered this post already in reports. Is it still not
working?

:

Hi everyone, using A02 on XP. Not a programmer but trying to get there. I
have a form (with a subform). On the subform a record is created, edited,
macro validated and saved. Have a btn to preview report. Have the following
in the OnOpen event of the report:

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

(I got the wordage: Forms![fSARMain]![fSAR].Form![Key] with the expression
builder. [Key] is the unique ID field on the subform.)

(fSAR is a subform)

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

With the form open to that record, I click the preview report btn and
receive a
dialog box titled "Enter Parameter Value" and where it would normally say
what I want like "what key?", instead it reads "00022005". If I type 00022005
into the parameter inquiry, the report opens with all records. Press enter on
the blank and get the ol' fav ERROR in all fields. UGGGHHH! Can't figure out
what I'm doing wrong!

I would appreciate any help or advice. Thanks in advance!
 
GREAT! We Got It. Yes, I meant for you to change that since I was not sure
what the field name is. The quotes in Where clauses always mess me up, too.
As long as I have been programming, I still have to try a few times to get in
right.

Bonnie said:
Thank you VERY much for the clarification. I did have to make one additional
alteration to your filter line:
Yours:
Me.Filter = "MyField = '" & Forms![fSARMain]![fSAR].Form![Key] & "'"
Mine:
Me.Filter = "[Key] = '" & Forms![fSARMain]![fSAR].Form![Key] & "'"

I had to change MyField to [Key]. It works now.

Thanks for sticking with this thread. It's the quotes that mess me up.
--
Bonnie


Klatuu said:
Sorry, Bonnie, did not mean to offend. I understand your frustration and I
am happy to try to help.
What you sent me is not correct, yet. Try looking in Acces Help for the
Filter Property. To correctly set a filter, it has to be Table Field Name =
Value To Filter On
Here is a cut and paste from Help:

Me.Filter = "Country = 'USA'"
Me.FilterOn = True

In the above case, Country is the name of the field in the table and USA is
the value to filter on.

That is why it is not working is that there is no comparison value here.
Also note the compare vaule needs to be in single quotes.
I don't know what the table field name is, but for this lets call it MyField

Your current code:
Me.Filter = Forms![fSARMain]![fSAR].Form![Key]
Me.FilterOn = True

I am assuming that Forms![fSARMain]![fSAR].Form![Key] is the control on your
form that contains the value you want to filter on. If so, then change your
code to:
Me.Filter = "MyField = '" & Forms![fSARMain]![fSAR].Form![Key] & "'"
Me.FilterOn = True

Again, I apologize for my comment. I did not mean for it to be as rude as
it looks.

Bonnie said:
I was becoming confused and felt a bit of attitude in your replies. My
purpose was to repost and try to communicate with someone else.

Your final post to me in the prior thread read:

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.

I understand that. My line contained the name of the field. The field
exists on a subform. It appears I have done what you said and it still gives
me the same parameter problem.

Please remember, I am not a skilled professional programmer. I am learning
VB but much of it seems illogical until placed in a context I can relate to.

If you care to continue, feel free but please come down to my level. Thank
you for participating in the newsgroups and trying to help.
--
Bonnie


:

Bonnie, I think I answered this post already in reports. Is it still not
working?

:

Hi everyone, using A02 on XP. Not a programmer but trying to get there. I
have a form (with a subform). On the subform a record is created, edited,
macro validated and saved. Have a btn to preview report. Have the following
in the OnOpen event of the report:

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

(I got the wordage: Forms![fSARMain]![fSAR].Form![Key] with the expression
builder. [Key] is the unique ID field on the subform.)

(fSAR is a subform)

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

With the form open to that record, I click the preview report btn and
receive a
dialog box titled "Enter Parameter Value" and where it would normally say
what I want like "what key?", instead it reads "00022005". If I type 00022005
into the parameter inquiry, the report opens with all records. Press enter on
the blank and get the ol' fav ERROR in all fields. UGGGHHH! Can't figure out
what I'm doing wrong!

I would appreciate any help or advice. Thanks in advance!
 
Back
Top