OpenReport help please

E

Erik T

I am receiving a runtime error code 3075 - missing operator when attempting
to execute the following OpenReport statement

Private Sub QueryResults_Click()

Dim rptName As String
Dim strWhere As String
Dim AggregateNumber As Single
Dim AggregateSpread As Single

rptName = "rptVariableResults"
AggregateNumber = InputBox("Aggregate Number Maximum ")
AggregateSpread = InputBox("Aggregate Spread Minimum ")

strWhere = "1agg <= " & AggregateNumber & " AND AggSpread => " &
AggregateSpread

DoCmd.OpenReport rptName, acViewPreview, , strWhere

End Sub

What I am trying to do is to allow a customized report based on user entered
values on two criteria 1agg and AggSpread. Your ideas on how I can get this
to work will be most appreciative. As always, I thank you for looking at this
scenario for me.
 
D

Dirk Goldgar

Erik T said:
I am receiving a runtime error code 3075 - missing operator when
attempting to execute the following OpenReport statement

Private Sub QueryResults_Click()

Dim rptName As String
Dim strWhere As String
Dim AggregateNumber As Single
Dim AggregateSpread As Single

rptName = "rptVariableResults"
AggregateNumber = InputBox("Aggregate Number Maximum ")
AggregateSpread = InputBox("Aggregate Spread Minimum ")

strWhere = "1agg <= " & AggregateNumber & " AND AggSpread => " &
AggregateSpread

DoCmd.OpenReport rptName, acViewPreview, , strWhere

End Sub

What I am trying to do is to allow a customized report based on user
entered values on two criteria 1agg and AggSpread. Your ideas on how
I can get this to work will be most appreciative. As always, I thank
you for looking at this scenario for me.

Is "1agg" the name of a field in your report's recordsource? If so, I
think maybe it needs to be enclosed in square brackets ([]) to be
interpreted correctly, since it starts with a numeral:

strWhere = "[1agg] <= " & AggregateNumber & _
" AND AggSpread => " & AggregateSpread
 
A

Allen Browne

You have a field name starting with a number.

You must use square brackets around that name:

strWhere = "[1agg] <= " & AggregateNumber & _
" AND AggSpread => " & AggregateSpread
 
E

Erik T

Dirk,
The square brackets helped but where only part of the solution. For some
reason the => and <= were also part of the problem. I solved this by removing
the = signs from both where conditions and manipulated the user input
variables to compensate for removing the equal sign.

If I may ask another question on this topic. How can I pass the user input
criteria to the report so I may add to the header?

Thanks for pointing me in the right direction.

Dirk Goldgar said:
Erik T said:
I am receiving a runtime error code 3075 - missing operator when
attempting to execute the following OpenReport statement

Private Sub QueryResults_Click()

Dim rptName As String
Dim strWhere As String
Dim AggregateNumber As Single
Dim AggregateSpread As Single

rptName = "rptVariableResults"
AggregateNumber = InputBox("Aggregate Number Maximum ")
AggregateSpread = InputBox("Aggregate Spread Minimum ")

strWhere = "1agg <= " & AggregateNumber & " AND AggSpread => " &
AggregateSpread

DoCmd.OpenReport rptName, acViewPreview, , strWhere

End Sub

What I am trying to do is to allow a customized report based on user
entered values on two criteria 1agg and AggSpread. Your ideas on how
I can get this to work will be most appreciative. As always, I thank
you for looking at this scenario for me.

Is "1agg" the name of a field in your report's recordsource? If so, I
think maybe it needs to be enclosed in square brackets ([]) to be
interpreted correctly, since it starts with a numeral:

strWhere = "[1agg] <= " & AggregateNumber & _
" AND AggSpread => " & AggregateSpread

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
A

Allen Browne

See:
Limiting a Report to a Date Range
at:
http://members.iinet.net.au/~allenbrowne/casu-08.html

Although the article is about dates, both the approaches outlined in the
article will work for you.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Erik T said:
Dirk,
The square brackets helped but where only part of the solution. For some
reason the => and <= were also part of the problem. I solved this by
removing
the = signs from both where conditions and manipulated the user input
variables to compensate for removing the equal sign.

If I may ask another question on this topic. How can I pass the user input
criteria to the report so I may add to the header?

Thanks for pointing me in the right direction.

Dirk Goldgar said:
Erik T said:
I am receiving a runtime error code 3075 - missing operator when
attempting to execute the following OpenReport statement

Private Sub QueryResults_Click()

Dim rptName As String
Dim strWhere As String
Dim AggregateNumber As Single
Dim AggregateSpread As Single

rptName = "rptVariableResults"
AggregateNumber = InputBox("Aggregate Number Maximum ")
AggregateSpread = InputBox("Aggregate Spread Minimum ")

strWhere = "1agg <= " & AggregateNumber & " AND AggSpread => " &
AggregateSpread

DoCmd.OpenReport rptName, acViewPreview, , strWhere

End Sub

What I am trying to do is to allow a customized report based on user
entered values on two criteria 1agg and AggSpread. Your ideas on how
I can get this to work will be most appreciative. As always, I thank
you for looking at this scenario for me.

Is "1agg" the name of a field in your report's recordsource? If so, I
think maybe it needs to be enclosed in square brackets ([]) to be
interpreted correctly, since it starts with a numeral:

strWhere = "[1agg] <= " & AggregateNumber & _
" AND AggSpread => " & AggregateSpread

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
D

Dirk Goldgar

Erik T said:
Dirk,
The square brackets helped but where only part of the solution. For
some reason the => and <= were also part of the problem. I solved
this by removing the = signs from both where conditions and
manipulated the user input variables to compensate for removing the
equal sign.

It appears that SQL doesn't accept "=>" as a valid operator; only its
equivalent, ">=". VBA accepts them both, so I didn't notice the flaw in
your criteria.
If I may ask another question on this topic. How can I pass the user
input criteria to the report so I may add to the header?

It looks to me like the approach in Allen Browne's article will best
serve you.
Thanks for pointing me in the right direction.

You're welcome.
 
E

Erik T

Allen,

Thanks for your reply and reference to your Tips page. This information was
easy to understand and adapt to solve my situation.

Allen Browne said:
See:
Limiting a Report to a Date Range
at:
http://members.iinet.net.au/~allenbrowne/casu-08.html

Although the article is about dates, both the approaches outlined in the
article will work for you.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Erik T said:
Dirk,
The square brackets helped but where only part of the solution. For some
reason the => and <= were also part of the problem. I solved this by
removing
the = signs from both where conditions and manipulated the user input
variables to compensate for removing the equal sign.

If I may ask another question on this topic. How can I pass the user input
criteria to the report so I may add to the header?

Thanks for pointing me in the right direction.

Dirk Goldgar said:
I am receiving a runtime error code 3075 - missing operator when
attempting to execute the following OpenReport statement

Private Sub QueryResults_Click()

Dim rptName As String
Dim strWhere As String
Dim AggregateNumber As Single
Dim AggregateSpread As Single

rptName = "rptVariableResults"
AggregateNumber = InputBox("Aggregate Number Maximum ")
AggregateSpread = InputBox("Aggregate Spread Minimum ")

strWhere = "1agg <= " & AggregateNumber & " AND AggSpread => " &
AggregateSpread

DoCmd.OpenReport rptName, acViewPreview, , strWhere

End Sub

What I am trying to do is to allow a customized report based on user
entered values on two criteria 1agg and AggSpread. Your ideas on how
I can get this to work will be most appreciative. As always, I thank
you for looking at this scenario for me.

Is "1agg" the name of a field in your report's recordsource? If so, I
think maybe it needs to be enclosed in square brackets ([]) to be
interpreted correctly, since it starts with a numeral:

strWhere = "[1agg] <= " & AggregateNumber & _
" AND AggSpread => " & AggregateSpread

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 

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