Re: DoCmd.OpenReport - WhereCondition

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Sorry you lost me on this one.

If the user does not enter anything into the combo boxes, then I would like
the where query to Print all records (*).

I have three combo boxes so there are 8 possible where clauses. Is there an
easier way to code this then writing an 8 tiered IF statement. Can I just
assign * to the field if it is nul?

Here is my current statement - assuming the user has entered a criteria in
each, it works.
strWhere = "[Country] = '" & Me!cmb_Country & "' and [Region] = '" &
Me!cmb_Region & "' and [ClientSector] = '" & Me!cmb_Sector & "'"

Thanks Again
AC
"fredg" wrote:

> On Thu, 11 Aug 2005 06:51:18 -0700, ACase wrote:
>
> > Perfect - Thank you.
> >
> > One additional question though, is how do I manage the Null values. If the
> > user does not select any values in the drop down.
> >
> > Thanks Again
> > AC
> >
> > "fredg" wrote:
> >
> >> On Wed, 10 Aug 2005 13:34:04 -0700, ACase wrote:
> >>
> >>> How do I employ multiple Where conditions.
> >>>
> >>> Example
> >>>
> >>> strWhereCountry = "Country = Forms![frmRptMenu]!cmb_Country"
> >>> strWhereRegion = "Region = Forms![frmRptMenu]!cmb_Region"
> >>>
> >>> DoCmd.OpenReport "rpt_New_Bus_Wins_by_Sector", PrintMode, strWhereCountry,
> >>> and strWhereRegion
> >>>
> >>> This is not working - is there a better way?
> >>>
> >>> Any help would be much appreciated.
> >>> AC
> >>
> >> Why do you need 2 separate string variables?
> >>
> >> Is the bound column of cmb_Country and cmb_Region a Text or Number
> >> datatype? Is that the same datatype as the datatype of [Country] and
> >> [Region]?
> >>
> >> If the combo bound columns and [Country] and [Region] fields are
> >> Number datatypes:
> >>
> >> Dim strWhere as String
> >>
> >> strWhere = "[Country] = " & Me!cmb_Country & " and [Region] = " &
> >> Me!cmb_Region
> >>
> >> If the combo bound columns and [Country] and [Region] fields are Text
> >> datatypes?
> >>
> >> strWhere = "[Country] = '" & Me!cmb_Country & "' and [Region] = '" &
> >> Me!cmb_Region & "'"
> >>
> >> DoCmd.OpenReport "rpt_New_Bus_Wins_by_Sector", acViewPreview, ,
> >> strWhere
> >>
> >> Note. You need to watch your comma placement.
> >> You had them incorrect in your OpenReport syntax.
> >> The strWhere clause goes in the Where clause argument, not in the
> >> filter argument position.
> >> DoCmd.OpenReport "Name", view, filter, where clause
> >> --
> >> Fred
> >> Please only reply to this newsgroup.
> >> I do not reply to personal email.
> >>
>
> It depends.
> What do you want to happen if nothing has been entered?
> Print all records? Print nothing?
> Show a message requesting an entry?
>
> You would first decide what you want to happen, then you can check for
> no combo entry by using:
> If IsNull(Me![cmb_Country]) Or IsNull(Me![cmb_Region]) Then
> Do this
> Else
> strWhere = "Etc."
> End If
>
> --
> Fred
> Please only reply to this newsgroup.
> I do not reply to personal email.
>
.



Relevant Pages

  • Re: Parameter query with multiple check boxes
    ... or more check boxes, then select OK and one dialog box apprears asking me to ... If I leave it blank the report appears with no ... Dim strWhere As String ... 'add to the where clause ...
    (microsoft.public.access.queries)
  • Re: Parameter query with multiple check boxes
    ... Name of the report? ... Dim strWhere As String ... 'find the true check boxes ... 'add to the where clause ...
    (microsoft.public.access.queries)
  • Re: Parameter query with multiple check boxes
    ... Do you know what your strWhere looks like just prior to opening the report? ... 'remove the last " or " from the where clause ... or more check boxes, then select OK and one dialog box apprears asking me ...
    (microsoft.public.access.queries)
  • Re: Parameter query with multiple check boxes
    ... Press Ctrl+G to open the immediate window and look for your strWhere value ... Does your form with the command button contain 25 check boxes? ... DoCmd.OpenReport "Type and Work Report", acViewPreview,, strWhere ... 'add to the where clause ...
    (microsoft.public.access.queries)
  • Re: use multiple combo boxes to filter table, results displayed in
    ... out the Combo boxes. ... out of Design view, then my form has automatically updated and the results ... Debug.Print strWhere ... Allen Browne - Microsoft MVP. ...
    (microsoft.public.access.formscoding)