Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2005

    Unanswered: Filtering with Visual Basic

    I'm trying to have a continuous form that allows my users to filter through a large database of names. I'm new to visual basic but need the functionalty that vb has over a macro. The problem occurs when filtering the letters Q and X because no data exists for them yet. I receive an error that states "Control can't be edited its data source has no current record." Then after I try to select another record (besides Q or X) I recieve the same error and have to completely exit out.

    I've attached the code.

    Please Help!

    Code for X (it doesn't work)

    If (alphabar = 24) Then
    ' Filter last names that start with X.
    DoCmd.ApplyFilter "", "[tblTrespass]![strLastName] Like ""X*"""
    End If

    Code for Z (it works)
    End If
    If (alphabar = 26) Then
    ' Filter last names that start with Z.
    DoCmd.ApplyFilter "", "[tblTrespass]![strLastName] Like ""Z*"""
    End If
    If (alphabar = 27) Then
    ' Show all names.
    End If

    If (RecordsetClone.RecordCount > 0) Then
    ' If records are returned for the selected letter, go to the AlphaBar control.
    DoCmd.GoToControl "alphabar"
    Exit Sub
    End If

    If (RecordsetClone.RecordCount = 0) Then
    ' If no records are returned for the selected letter, display a message.
    MsgBox "There are no records for that letter.", vbInformation, "No Records Returned"
    ' Show all records.
    ' Press in the All button.
    alphabar = 27
    End If

    Exit Sub

    MsgBox Error$
    Resume alphabar_AfterUpdate_Exit

    End Sub

  2. #2
    Join Date
    Jan 2006
    opps wrong post

Posting Permissions

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