Results 1 to 6 of 6

Record filtering through Combo box

  1. #1
    glen is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    171

    Record filtering through Combo box

    Hi all,
    I have form with sub form. There is a combo on form which filter records of many orders in sub form.
    Now the problem is if I put an order name in combo which is not exist and press enter it also show me record of first order.
    I want that if I enter an order which not exist in Record then it should give me a message that " This order not exist.


    Thanks.
    here is my code in after update event of combo.
    Code:
    Private Sub CBOBATCH_AfterUpdate()
    'Find the that matches the control
       Dim rs As Object
       Set rs = Me.Recordset.Clone
    
       'check if there is a batch number
       If Len(Trim(Me.CBOBATCH)) > 0 Then
          rs.FindFirst "[batchno]='" & Me![CBOBATCH] & "'"
          If Not rs.EOF Then
             Me.Bookmark = rs.Bookmark
          End If
       Else
          DoCmd.GoToRecord , , acNewRec
          
       End If
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    16,185
    I think you want to test for NoMatch rather than EOF. The recordset isn't EOF if there are records on the form.
    Paul (wino moderator)
    MS Access MVP
    www.BaldyWeb.com

  3. #3
    glen is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    171
    I don't know about EOF and no match.
    I just saw this code in one database which was filtering records of sub form and I also use this code here.

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    16,185
    You want something like the test here:

    http://www.baldyweb.com/Bookmark.htm
    Paul (wino moderator)
    MS Access MVP
    www.BaldyWeb.com

  5. #5
    glen is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    171
    Thanks Solved.

  6. #6
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    16,185
    No problem.
    Paul (wino moderator)
    MS Access MVP
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 1
    Last Post: 07-12-2012, 07:39 AM
  2. Replies: 5
    Last Post: 03-12-2012, 01:58 AM
  3. Combo Box Not filtering
    By ss2020 in forum Forms
    Replies: 4
    Last Post: 01-17-2012, 12:16 PM
  4. Combo Box Filtering between Forms
    By andrew_ww in forum Access
    Replies: 3
    Last Post: 12-30-2009, 10:06 PM
  5. Replies: 0
    Last Post: 08-17-2008, 11:19 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
  •  
Tech Forums: Microsoft Office Forums