Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help Why wont this code work 1

Status
Not open for further replies.

cbiker

Programmer
Jul 2, 2003
35
US
Still learning
trying to open report with to criteria from report form with pick lists here is the code

Dim strWhereCombo As String

strWhereCombo = "USC = Forms![Report Print Form]!SIUSelect" & "Parameter = Forms![Report Print Form]!ParameterSelect"

DoCmd.OpenReport “Metals” , acViewPreview, , strWhereCombo
Any help would be much appreciated.
 
Hi!

From F1 on openreport, you'll find the where condition is a valid sql where clause without the word 'Where'.

In your example, it might work using:

[tt]strWhereCombo = "USC = " & Forms![Report Print Form]!SIUSelect & " AND Parameter = " & Forms![Report Print Form]!ParameterSelect[/tt]

if numeric. If text, perhaps:

[tt]strWhereCombo = "USC = '" & Forms![Report Print Form]!SIUSelect & "' AND Parameter = '" & Forms![Report Print Form]!ParameterSelect & "'"[/tt]

HTH Roy-Vidar
 
RoyVidar
Thanks for the Help works like a Charm. One Question is there a book I could buy that would help Me understand Strings and such a little better.A star for the help.

Cbiker

 
Hi again!

Thanx for the star!

Most books covering Access VBA would have something on strings in criterias. But now, you nearly have it all;-)
[tt]
"MyNumericField = " & Me!NumericControl ' No qualifier
"MyDateField = #" & Me!DateControl & "#" ' Hash (#)
"MyTextField = '" & Me!TextControl & "'" ' Apostrophe (')[/tt]

- something I completely forgot in the first reply, if you're doing this whithin the form module of the form you refere too, you could replace the "Forms!Formname" part of the reference with the "Me" keyword.

Only, both books and F1 mostly give one field/one criteria examples, so studing some sql (sql view of a query?) where clauses, adding qualifiers, and voila;-)

Recommend a specific book for strings, no sorry, but take a look in a bookstore having something to choose from, see if you like the style and examples - check that the book either contain a CD with examples or a website where you can download examples.

- another great supply of information, is to browse threads here at TT, do a keyword search on report, criteria, open or perhaps where condition etc, and there are multiple hits.

Roy-Vidar
 
Sorry it took so long to get back been busy.
Anyway thanks for all the Help.[thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top