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

    Filter question (2000)

    Hi,
    I have a start-up form called FrmStart, where the user selects 3 available sections to choose from in a combo box (cboSection). So for instance, Admin, Pay, Pensions. They then click an OK command button that opens FrmMain.
    The coding on the button includes:
    <hr>DoCmd.OpenForm "FrmMain", , , , , , Me.CboSection<hr>
    FrmMain is then opened from this. FrmMain is based on TblMain, with various linked tables. In the Table there is a field called Section. This is determined by the selection made in CboSection.
    1) Can I record the selection made in CboSection in TblMain.Section where a user records a new record in FrmMain? So for instance, user selects Admin from FrmStart, and then adds a record to FrmMain. Admin is added in the field Section and the user is only able to view all records that relate to Admin, nothing else.

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

    Re: Filter question (2000)

    You can set a where-condition when opening the form:

    DoCmd.OpenForm "FrmMain", , , "[Section] = " & Chr(34) & Me.CboSection & Chr(34) , , , Me.CboSection

    This will restrict the form to records whose Section corresponds to the value selected in the combo box. I assumed that Section is a text field. You already pass the value of the combo box in the OpenArgs argument of OpenForm. You can use this in the On Load event of FrmMain to set the default value for Section:

    Private Sub Form_Load()
    Me.[Section].DefaultValue = Chr(34) & Me.OpenArgs & Chr(34)
    End Sub

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

    Re: Filter question (2000)

    Thanks Hans, much appreciated! <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

Posting Permissions

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