Results 1 to 5 of 5
  1. #1
    iankerry is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2010
    Posts
    3

    launching form with filter from other form

    Hi

    I am probably missing something obvious perhaps someone can help?

    I have a form for dvd's. On it i have a barcode field, and when i scan a dvd it enters the ID number of the film and goes and finds the record. here is the code for it:

    Private Sub Text107_AfterUpdate()
    If Text107 <> "" Then

    Me.RecordsetClone.FindFirst "dbo_films.[id] = " & DLookup("tblfilms_id", "dbo_filmcopies", "ID = " & Text107.Value)
    Me.Bookmark = Me.RecordsetClone.Bookmark
    [frmFilmSub - Alternative].Form.FilterOn = True
    [frmFilmSub - Alternative].Form.Filter = "id = " & Text107.Value
    [frmFilmSub - Alternative].Form.Requery
    End If
    End Sub

    This works well. But what i would like to do is have a barcode search box on another form, that loads another form with the correct dvd showing. so i thought i could use the same code, tweak it and hey presto, but no.

    Private Sub Text107_AfterUpdate()
    If Text107 <> "" Then
    DoCmd.OpenForm "frmFilmSub - Alternative"
    Me.RecordsetClone.FindFirst "dbo_films.[id] = " & DLookup("tblfilms_id", "dbo_filmcopies", "ID = " & Text107.Value)
    Me.Bookmark = Me.RecordsetClone.Bookmark
    [frmFilmSub - Alternative].Form.FilterOn = True
    [frmFilmSub - Alternative].Form.Filter = "id = " & Text107.Value
    [frmFilmSub - Alternative].Form.Requery
    End If
    End Sub

    All I have changed is really opening the form. The code falls down because it can't find the dbo_films.id field (r/t error 3070). Which of course is on the form, as i use it in the other routine.



    have i not referenced the new form correctly?

    thanks
    ian

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Are you aware of the fact that the WhereCondition argument of the OpenForm function applies a filter to the target form?

  3. #3
    iankerry is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2010
    Posts
    3
    Quote Originally Posted by RuralGuy View Post
    Are you aware of the fact that the WhereCondition argument of the OpenForm function applies a filter to the target form?
    I was but didnt think of it - thanks.

    replacing all that code with

    DoCmd.OpenForm "frmFilmSub - Alternative", acNormal, , "[ID] =" & Text107.Value

    works a treat!

    Thanks

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You're welcome. It was the old forest hiding behind the trees bit.

  5. #5
    iankerry is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2010
    Posts
    3
    it's funny how often i get lost in lost in those trees!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 11-25-2013, 10:56 AM
  2. Filter by Form? Confused...
    By andmunn in forum Forms
    Replies: 0
    Last Post: 01-14-2010, 01:30 PM
  3. Checkbox filter on a form
    By aletrindade in forum Access
    Replies: 1
    Last Post: 12-02-2009, 06:22 AM
  4. Form Combobox filter
    By westcoastbmx in forum Forms
    Replies: 0
    Last Post: 10-20-2009, 11:27 PM
  5. Filter Form records with Combo Box????
    By jgelpi in forum Forms
    Replies: 0
    Last Post: 05-19-2009, 07:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums