Results 1 to 8 of 8
  1. #1
    Join Date
    May 2004
    Posts
    144

    Unanswered: creating a list box from table with an extra item

    hi
    i have a list box which its row source is a table. but i want to add anothe extra item ("All Items" with value number 0) to this listbox. this is for filter page that goes to report page.
    how can i add this?

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14

  3. #3
    Join Date
    May 2004
    Posts
    144
    tanX Sinndho, & a relevant question:
    i made that form with All-Types(id=0) & list of Types from tblTypes.
    now i come to make report & i made it.
    when user select All-Types(id=0) from the list, report must show all the products whith any types, for this i put this code in report Filter:
    Code:
    type_id = IIf(TempVars!type=0, X , TempVars!type)
    what am i suppose to put in this expression for X ?

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    What do you use type_id for ?
    Have a nice day!

  5. #5
    Join Date
    May 2004
    Posts
    144
    type_id is a filter, i want to select records with user selected type_id.
    suppose i have tblVehicles & tblTypes. user select type_id and list all the vehicles from that type.

  6. #6
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    type_id cannot be a filter in itself: it's a numeric value, while a filter or a criteria must be a string.

    If you build the filter with something like:
    Code:
        strFilter = "type_id = " & type_id
    then your code should become:
    Code:
        type_id = TempVars!type
        If type_id = 0 Then
           strFilter = ""
        Else
            strFilter = "type_id = " & type_id 
         End If
    or:
    Code:
        type_id = TempVars!type
        strFilter = IIf(Type_id = 0, "", "type_id = " & type_id)
    or even shorter:
    Code:
        strFilter = IIf(TempVars!type = 0, "", "type_id = " & TempVars!type )
    Then you can open the report:
    Code:
        DoCmd.OpenReport "<Report Name>", , , strFilter
    Have a nice day!

  7. #7
    Join Date
    May 2004
    Posts
    144
    yes, but i want an expression for using it in filter property. not writing code.

  8. #8
    Join Date
    May 2004
    Posts
    144
    this one worked out:
    Code:
    type_id = IIf(TempVars!type=0, type_id , TempVars!type)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •