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

    Default form view (2K)

    Hi,
    I'm a bit unsure what to do........
    I have a form that records data and the user has the option of archiving records that have been dealt with.
    This form has a field in it called Archive. This is a true/false value.
    I have now placed a combobox, CboArchiveView that also has a true/false value(although this has been replaced with text, Archived and Live). What I want to do is only display those records that relate to the value in CboArchiveView. So if CboArchiveView = True (Archived) then this will filter the values in the main form that have a field value in Archive of True. Then if its changed back to false, this will display all live files.
    I hope that makes sense!
    I don't know whether it effects anything, but I also have an OpenArg on the main form that filters on Areas.

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

    Re: Default form view (2K)

    1) Do you want the user to have the option to display ALL records (those with Archive = True and those with Archive = False)?

    2) Do you want to keep the filter on Areas when the user selects True or False from the combo box?

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

    Re: Default form view (2K)

    1)No, the users will only need to view either, or.
    2)Yes as each use only works in a specific area, so ideally I don't want to alter this.

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

    Re: Default form view (2K)

    Thanks. What is the situation when the form is opened? Are only "live" records displayed? And if so, how is this done?

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

    Re: Default form view (2K)

    Currently the situation is that the form displays all records.
    However due to the records beginning to mount in volume I feel that it would be beneficial to archive records.
    I now have CboArchive that has a Yes/No text, otherwise True & False. The users are now beginning to archive their old records so that they can be filtered out.
    I thought it would make sense to have the ability to view both archived and live files on the same form, albeit individually. I added CboArchiveView to deal with this. The default value would be the live files, so that whenever the user opens the database the live ones are displayed.

    To begin with I was going to add the coding in the OpenArg so that all archived files were not viewed, but because of the users ability to change the archive view, I didn't think this would work.

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

    Re: Default form view (2K)

    You can expand the filter in the On Open or On Load event of the form to include only records with Archive = True. It'll look a bit like

    Me.Filter = "Area = " & Me.OpenArgs & " AND Archive = True"

    You can change the filter in the After Update event of the combo box. More or less like this:

    Private Sub cboArchive_AfterUpdate()
    If Me.cboArchive = "True" Then
    Me.Filter = Replace(Me.Filter, "False", "True")
    Else
    Me.Filter = Replace(Me.Filter, "True", "False")
    End If
    Me.FilterOn = True
    End Sub

    Details depend on the exact setup of your combo box.

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

    Re: Default form view (2K)

    Sorry I'll just have to confirm........

    The Open event of FrmMain is:

    Private Sub Form_Open(Cancel As Integer)
    Me.[AreaID].DefaultValue = Chr(34) & Me.OpenArgs & Chr(34)
    Me.URN.SetFocus

    End Sub

    Should this be changed to

    Private Sub Form_Open(Cancel As Integer)
    Me.[AreaID].DefaultValue = Chr(34) & Me.OpenArgs & Chr(34) & Filter="True"
    Me.URN.SetFocus

    End Sub

    The coding with regards to CboArchiveView is fine if this is the case.

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

    Re: Default form view (2K)

    The code to set the default value of AreaID shouldn't be changed. Try this:

    Private Sub Form_Open(Cancel As Integer)
    Me.[AreaID].DefaultValue = Chr(34) & Me.OpenArgs & Chr(34)
    Me.Filter = "Archive = True"
    Me.FilterOn = True
    Me.URN.SetFocus
    End Sub

    You can probably simplify the After Update code for the combo box to

    Private Sub cboArchive_AfterUpdate()
    Me.Filter = "Archive = " & Me.cboArchive
    Me.FilterOn = True
    End Sub

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

    Re: Default form view (2K)

    Mmmm. Still having problems, seems to be an issue with CboArchiveView & CboArchive on FrmMain

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

    Re: Default form view (2K)

    1) CboArchiveView should NOT be bound to the Archive field. It must be unbound, since you don't use it to set the status of the current record, but to specify which records should be displayed.
    2) You have put the code to change the filter in CboSolicitor_AfterUpdate. This makes no sense. It should be in CboArchiveView_AfterUpdate.
    3) If the user is not one of a few specified in the code, you set AllowEdits to False. This makes it impossible to select a value in CboArchiveView. You could lock all bound controls instead.

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

    Re: Default form view (2K)

    Sorry Hans, my fault. I was trying to rush it through as it is a live system and is normally used all day, every day.
    I think I have now resolved this.
    My only question is I need to now filter the records in CboFindRecord.

    The RowSource is

    SELECT TblMain.DefSurname, TblMain.DefForename, TblMain.URN, TblMain.AreaID, TblMain.Archive FROM TblMain WHERE (((TblMain.AreaID)=2) AND ((TblMain.Archive)=False)) ORDER BY TblMain.DefSurname;

    But this will need to adjust dependant upon the value in CboArchiveView so that the user can have a list of files dependant upon whether their archived or live.

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

    Re: Default form view (2K)

    Try

    SELECT TblMain.DefSurname, TblMain.DefForename, TblMain.URN, TblMain.AreaID, TblMain.Archive FROM TblMain WHERE (((TblMain.AreaID)=2) AND ((TblMain.Archive)=[Forms]![frmMain]![cboArchiveView])) ORDER BY TblMain.DefSurname;

    You will have to requery cboFindRecord in the After Update event of cboArchiveView:

    Private Sub cboArchiveView_AfterUpdate()
    ... (existing code)
    ...
    Me.cboFindRecord.Requery
    End Sub

    Note: I assume that the value 2 for AreaID is changed dynamically.

Posting Permissions

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