Results 1 to 7 of 7
  1. #1
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form filter question (2K)

    HI,
    I know this is a stupid question and I feel that I should know it, but....

    I have an OpenArg on a form that filters all records based on a geographical area. So the person opening it can only view records for the area selected from a previous form. All records added within this session get allocated to that selected area.

    This is fine and dandy. However I also want to filter the form based on whether records have a field [Casedead] = 0. i.e. The record is live.

    I did simply add

    , [Casedead]=False

    on the end of the filter, making it look like:

    [AreaName] = "Norwich", [CaseDead]=0

    But it didn't seem to work, am I missing something?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Form filter question (2K)

    The filter should be

    [AreaName] = "Norwich" AND [CaseDead]=0

  3. #3
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form filter question (2K)

    Hmmm,
    It still appears to be showing!

    The text in " "

    [AreaName] = "Norwich"

    part of the filter is set by the openarg, I don't know whether this matters

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Form filter question (2K)

    You'll have to explain more clearly what you mean by
    <hr>It still appears to be showing!

    The text in " "

    [AreaName] = "Norwich"<hr>
    and how exactly you are trying to filter.

  5. #5
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form filter question (2K)

    Hi,
    Sorry, I'll explain in more detail.
    The records that should be filtered from view are still displayed. This is where their value of [CaseDead]=0.

    I wondered whether this is because of the open arg.

    The openarg is accessed through a user selecting an area in FrmStartUp from a combobox, CboArea.
    The Onclick event of a control (CmdOpenMain) on that form is:

    Private Sub CmdOpenMain_Click()
    On Error GoTo Err_CmdOpen_Click
    DoCmd.OpenForm "FrmMain", , , "[AreaName] = " & Chr(34) & Me.CboArea & Chr(34), , , Me.CboArea
    Exit_CmdOpen_Click:
    Exit Sub

    Err_CmdOpen_Click:
    MsgBox "Please select a Unit!", vbOKOnly, "Error!"
    Resume Exit_CmdOpen_Click

    End Sub

    This then opens FrmMain.

    On the Open event of FrmMain is the following:

    Private Sub Form_Open(Cancel As Integer)
    Me.AreaName.DefaultValue = Chr(34) & Me.OpenArgs & Chr(34)
    End Sub

    This is what sets the filter value in the design view to:

    [AreaName] = " Area Selected "

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Form filter question (2K)

    The On Open event procedure of the form doesn't filter the records, it only sets the Default Value property of the AreaName control. The records are filtered by the WhereCondition argument of DoCmd.OpenForm:

    DoCmd.OpenForm "FrmMain", , , "[AreaName] = " & Chr(34) & Me.CboArea & Chr(34), , , Me.CboArea

    You can expand this argument:

    DoCmd.OpenForm "FrmMain", , , "[AreaName] = " & Chr(34) & Me.CboArea & Chr(34) & " AND [CaseDead] = 0", , , Me.CboArea

  7. #7
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form filter question (2K)

    Thanks Hans, problem solved!!!!

Posting Permissions

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