Results 1 to 4 of 4
  1. #1
    Join Date
    May 2003
    Location
    UK
    Posts
    233

    Unanswered: What is wrong with this code?

    I am trying to filter data when the form loads.

    When I open the form from design mode this works. When I open it from the switchboard no filter is applied (all data is shown)

    Any ideas!!!!

  2. #2
    Join Date
    May 2003
    Location
    UK
    Posts
    233

    What is wrong with this code?

    Sorry might help if I show you the code

    Private Sub Form_Load()

    'Hide all fields and then show depending on selection
    cmbEmpNo.Visible = False

    'Achive records on form load
    DoCmd.ApplyFilter "archive", "[cust_query]![hide_query]=No"

    'got to last record
    DoCmd.GoToRecord , , acLast


    End Sub

  3. #3
    Join Date
    May 2002
    Location
    London
    Posts
    87
    To Filter a form from code I would use

    Me.Filter = "[AField] =" & lngValue
    Me.FilterOn = True

    or

    Me.Filter = "[AnotherField] ='" & strValue & "'"
    Me.FilterOn = True

    If it was a text field we were filtering on.

  4. #4
    Join Date
    May 2003
    Location
    UK
    Posts
    233
    Nice one

    Thanks Risky

    its easy when you know how

Posting Permissions

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