Report Filter Question

G

Golfinray

I have a report called 06-07 Active Projects. I am trying to use a command
button on a form to filter it. The report has a field "date plans received" I
would just like the report to open from a command button on a form with only
those records that have a date plans received filled in. I have been trying
to use the where condition on the command button like so:
Private Sub Command0_Click()
Dim strwhere As String
strwhere = "[date plans received] = """ & Me.[date plans received] & """"
DoCmd.OpenReport "06-07 active projects", acViewPreview, , strwhere
End Sub

I can't get this thing to work. It keeps giving me syntax or expression
errors. What am I doing wrong? Help! Thanks, a bunch!!!
 
D

Duane Hookom

It isn't clear what you want. However you could try use # to delimit your date

strwhere = "[date plans received] = #" & Me.[date plans received] & "#"

This assumes you use date formats like m/d/y.
 
G

Golfinray

I would like the report to open with only those records showing that have a
[date plans received] date.

Duane Hookom said:
It isn't clear what you want. However you could try use # to delimit your date

strwhere = "[date plans received] = #" & Me.[date plans received] & "#"

This assumes you use date formats like m/d/y.
--
Duane Hookom
Microsoft Access MVP


Golfinray said:
I have a report called 06-07 Active Projects. I am trying to use a command
button on a form to filter it. The report has a field "date plans received" I
would just like the report to open from a command button on a form with only
those records that have a date plans received filled in. I have been trying
to use the where condition on the command button like so:
Private Sub Command0_Click()
Dim strwhere As String
strwhere = "[date plans received] = """ & Me.[date plans received] & """"
DoCmd.OpenReport "06-07 active projects", acViewPreview, , strwhere
End Sub

I can't get this thing to work. It keeps giving me syntax or expression
errors. What am I doing wrong? Help! Thanks, a bunch!!!
 
D

Duane Hookom

I would have expected your reply to include something like "I made the change
you suggested and it works great" or "I still get an error"....
--
Duane Hookom
Microsoft Access MVP


Golfinray said:
I would like the report to open with only those records showing that have a
[date plans received] date.

Duane Hookom said:
It isn't clear what you want. However you could try use # to delimit your date

strwhere = "[date plans received] = #" & Me.[date plans received] & "#"

This assumes you use date formats like m/d/y.
--
Duane Hookom
Microsoft Access MVP


Golfinray said:
I have a report called 06-07 Active Projects. I am trying to use a command
button on a form to filter it. The report has a field "date plans received" I
would just like the report to open from a command button on a form with only
those records that have a date plans received filled in. I have been trying
to use the where condition on the command button like so:
Private Sub Command0_Click()
Dim strwhere As String
strwhere = "[date plans received] = """ & Me.[date plans received] & """"
DoCmd.OpenReport "06-07 active projects", acViewPreview, , strwhere
End Sub

I can't get this thing to work. It keeps giving me syntax or expression
errors. What am I doing wrong? Help! Thanks, a bunch!!!
 
G

Golfinray

I still get an error in syntax.

Duane Hookom said:
I would have expected your reply to include something like "I made the change
you suggested and it works great" or "I still get an error"....
--
Duane Hookom
Microsoft Access MVP


Golfinray said:
I would like the report to open with only those records showing that have a
[date plans received] date.

Duane Hookom said:
It isn't clear what you want. However you could try use # to delimit your date

strwhere = "[date plans received] = #" & Me.[date plans received] & "#"

This assumes you use date formats like m/d/y.
--
Duane Hookom
Microsoft Access MVP


:

I have a report called 06-07 Active Projects. I am trying to use a command
button on a form to filter it. The report has a field "date plans received" I
would just like the report to open from a command button on a form with only
those records that have a date plans received filled in. I have been trying
to use the where condition on the command button like so:
Private Sub Command0_Click()
Dim strwhere As String
strwhere = "[date plans received] = """ & Me.[date plans received] & """"
DoCmd.OpenReport "06-07 active projects", acViewPreview, , strwhere
End Sub

I can't get this thing to work. It keeps giving me syntax or expression
errors. What am I doing wrong? Help! Thanks, a bunch!!!
 
D

Duane Hookom

Do you get an error opening the report without using code?

What is your exact code? Do you have a text box on your form named "date
plans received"? Is there a field in your report's record source named "Date
plans received"?

Try add a line of code after "strwhere = ..." of
MsgBox "strwhere: " & strWhere
What do you see in the message box? Does it look reasonable?

--
Duane Hookom
Microsoft Access MVP


Golfinray said:
I still get an error in syntax.

Duane Hookom said:
I would have expected your reply to include something like "I made the change
you suggested and it works great" or "I still get an error"....
--
Duane Hookom
Microsoft Access MVP


Golfinray said:
I would like the report to open with only those records showing that have a
[date plans received] date.

:

It isn't clear what you want. However you could try use # to delimit your date

strwhere = "[date plans received] = #" & Me.[date plans received] & "#"

This assumes you use date formats like m/d/y.
--
Duane Hookom
Microsoft Access MVP


:

I have a report called 06-07 Active Projects. I am trying to use a command
button on a form to filter it. The report has a field "date plans received" I
would just like the report to open from a command button on a form with only
those records that have a date plans received filled in. I have been trying
to use the where condition on the command button like so:
Private Sub Command0_Click()
Dim strwhere As String
strwhere = "[date plans received] = """ & Me.[date plans received] & """"
DoCmd.OpenReport "06-07 active projects", acViewPreview, , strwhere
End Sub

I can't get this thing to work. It keeps giving me syntax or expression
errors. What am I doing wrong? Help! Thanks, a bunch!!!
 
G

Golfinray

Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

Dim stDocName As String
Dim strwhere As String
strwhere = "[date plans received] = #" & Me.[date plans received] & "#"
MsgBox "strwhere: " & strwhere
stDocName = "06-07 Active Projects"
DoCmd.OpenReport stDocName, acPreview, , strwhere

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click

End Sub

Exact Code. It tells me it can't find the field refered to in your
expression. A text box is on the report with "date plans received." There is
a field in the recordsource of the report for "date plans received." I added
the line you told me - it never got to it. It breaks at the strwhere line.
Thanks

Duane Hookom said:
Do you get an error opening the report without using code?

What is your exact code? Do you have a text box on your form named "date
plans received"? Is there a field in your report's record source named "Date
plans received"?

Try add a line of code after "strwhere = ..." of
MsgBox "strwhere: " & strWhere
What do you see in the message box? Does it look reasonable?

--
Duane Hookom
Microsoft Access MVP


Golfinray said:
I still get an error in syntax.

Duane Hookom said:
I would have expected your reply to include something like "I made the change
you suggested and it works great" or "I still get an error"....
--
Duane Hookom
Microsoft Access MVP


:

I would like the report to open with only those records showing that have a
[date plans received] date.

:

It isn't clear what you want. However you could try use # to delimit your date

strwhere = "[date plans received] = #" & Me.[date plans received] & "#"

This assumes you use date formats like m/d/y.
--
Duane Hookom
Microsoft Access MVP


:

I have a report called 06-07 Active Projects. I am trying to use a command
button on a form to filter it. The report has a field "date plans received" I
would just like the report to open from a command button on a form with only
those records that have a date plans received filled in. I have been trying
to use the where condition on the command button like so:
Private Sub Command0_Click()
Dim strwhere As String
strwhere = "[date plans received] = """ & Me.[date plans received] & """"
DoCmd.OpenReport "06-07 active projects", acViewPreview, , strwhere
End Sub

I can't get this thing to work. It keeps giving me syntax or expression
errors. What am I doing wrong? Help! Thanks, a bunch!!!
 
D

Duane Hookom

Did you use Option Explicit in your code? Does it compile? Are you sure you
have a text box on your form named [date plans received] ?


--
Duane Hookom
Microsoft Access MVP


Golfinray said:
Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

Dim stDocName As String
Dim strwhere As String
strwhere = "[date plans received] = #" & Me.[date plans received] & "#"
MsgBox "strwhere: " & strwhere
stDocName = "06-07 Active Projects"
DoCmd.OpenReport stDocName, acPreview, , strwhere

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click

End Sub

Exact Code. It tells me it can't find the field refered to in your
expression. A text box is on the report with "date plans received." There is
a field in the recordsource of the report for "date plans received." I added
the line you told me - it never got to it. It breaks at the strwhere line.
Thanks

Duane Hookom said:
Do you get an error opening the report without using code?

What is your exact code? Do you have a text box on your form named "date
plans received"? Is there a field in your report's record source named "Date
plans received"?

Try add a line of code after "strwhere = ..." of
MsgBox "strwhere: " & strWhere
What do you see in the message box? Does it look reasonable?

--
Duane Hookom
Microsoft Access MVP


Golfinray said:
I still get an error in syntax.

:

I would have expected your reply to include something like "I made the change
you suggested and it works great" or "I still get an error"....
--
Duane Hookom
Microsoft Access MVP


:

I would like the report to open with only those records showing that have a
[date plans received] date.

:

It isn't clear what you want. However you could try use # to delimit your date

strwhere = "[date plans received] = #" & Me.[date plans received] & "#"

This assumes you use date formats like m/d/y.
--
Duane Hookom
Microsoft Access MVP


:

I have a report called 06-07 Active Projects. I am trying to use a command
button on a form to filter it. The report has a field "date plans received" I
would just like the report to open from a command button on a form with only
those records that have a date plans received filled in. I have been trying
to use the where condition on the command button like so:
Private Sub Command0_Click()
Dim strwhere As String
strwhere = "[date plans received] = """ & Me.[date plans received] & """"
DoCmd.OpenReport "06-07 active projects", acViewPreview, , strwhere
End Sub

I can't get this thing to work. It keeps giving me syntax or expression
errors. What am I doing wrong? Help! Thanks, a bunch!!!
 
G

Golfinray

I did not use option explicit. I do have a text box named date plans
received. There are only dates there. Where would I put option explicit? Up
at the top where it says option compare?

Duane Hookom said:
Did you use Option Explicit in your code? Does it compile? Are you sure you
have a text box on your form named [date plans received] ?


--
Duane Hookom
Microsoft Access MVP


Golfinray said:
Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

Dim stDocName As String
Dim strwhere As String
strwhere = "[date plans received] = #" & Me.[date plans received] & "#"
MsgBox "strwhere: " & strwhere
stDocName = "06-07 Active Projects"
DoCmd.OpenReport stDocName, acPreview, , strwhere

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click

End Sub

Exact Code. It tells me it can't find the field refered to in your
expression. A text box is on the report with "date plans received." There is
a field in the recordsource of the report for "date plans received." I added
the line you told me - it never got to it. It breaks at the strwhere line.
Thanks

Duane Hookom said:
Do you get an error opening the report without using code?

What is your exact code? Do you have a text box on your form named "date
plans received"? Is there a field in your report's record source named "Date
plans received"?

Try add a line of code after "strwhere = ..." of
MsgBox "strwhere: " & strWhere
What do you see in the message box? Does it look reasonable?

--
Duane Hookom
Microsoft Access MVP


:

I still get an error in syntax.

:

I would have expected your reply to include something like "I made the change
you suggested and it works great" or "I still get an error"....
--
Duane Hookom
Microsoft Access MVP


:

I would like the report to open with only those records showing that have a
[date plans received] date.

:

It isn't clear what you want. However you could try use # to delimit your date

strwhere = "[date plans received] = #" & Me.[date plans received] & "#"

This assumes you use date formats like m/d/y.
--
Duane Hookom
Microsoft Access MVP


:

I have a report called 06-07 Active Projects. I am trying to use a command
button on a form to filter it. The report has a field "date plans received" I
would just like the report to open from a command button on a form with only
those records that have a date plans received filled in. I have been trying
to use the where condition on the command button like so:
Private Sub Command0_Click()
Dim strwhere As String
strwhere = "[date plans received] = """ & Me.[date plans received] & """"
DoCmd.OpenReport "06-07 active projects", acViewPreview, , strwhere
End Sub

I can't get this thing to work. It keeps giving me syntax or expression
errors. What am I doing wrong? Help! Thanks, a bunch!!!
 
D

Duane Hookom

The Option Explicit goes way at the top of your modules in the General
Declarations section. What happens if you change the name of your text box
to "txtDatePlansRecvd" and change your code to reflect the change?


--
Duane Hookom
Microsoft Access MVP


Golfinray said:
I did not use option explicit. I do have a text box named date plans
received. There are only dates there. Where would I put option explicit? Up
at the top where it says option compare?

Duane Hookom said:
Did you use Option Explicit in your code? Does it compile? Are you sure you
have a text box on your form named [date plans received] ?


--
Duane Hookom
Microsoft Access MVP


Golfinray said:
Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

Dim stDocName As String
Dim strwhere As String
strwhere = "[date plans received] = #" & Me.[date plans received] & "#"
MsgBox "strwhere: " & strwhere
stDocName = "06-07 Active Projects"
DoCmd.OpenReport stDocName, acPreview, , strwhere

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click

End Sub

Exact Code. It tells me it can't find the field refered to in your
expression. A text box is on the report with "date plans received." There is
a field in the recordsource of the report for "date plans received." I added
the line you told me - it never got to it. It breaks at the strwhere line.
Thanks

:

Do you get an error opening the report without using code?

What is your exact code? Do you have a text box on your form named "date
plans received"? Is there a field in your report's record source named "Date
plans received"?

Try add a line of code after "strwhere = ..." of
MsgBox "strwhere: " & strWhere
What do you see in the message box? Does it look reasonable?

--
Duane Hookom
Microsoft Access MVP


:

I still get an error in syntax.

:

I would have expected your reply to include something like "I made the change
you suggested and it works great" or "I still get an error"....
--
Duane Hookom
Microsoft Access MVP


:

I would like the report to open with only those records showing that have a
[date plans received] date.

:

It isn't clear what you want. However you could try use # to delimit your date

strwhere = "[date plans received] = #" & Me.[date plans received] & "#"

This assumes you use date formats like m/d/y.
--
Duane Hookom
Microsoft Access MVP


:

I have a report called 06-07 Active Projects. I am trying to use a command
button on a form to filter it. The report has a field "date plans received" I
would just like the report to open from a command button on a form with only
those records that have a date plans received filled in. I have been trying
to use the where condition on the command button like so:
Private Sub Command0_Click()
Dim strwhere As String
strwhere = "[date plans received] = """ & Me.[date plans received] & """"
DoCmd.OpenReport "06-07 active projects", acViewPreview, , strwhere
End Sub

I can't get this thing to work. It keeps giving me syntax or expression
errors. What am I doing wrong? Help! Thanks, a bunch!!!
 

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