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.
Code for X (it doesn't work)
If (alphabar = 24) Then
' Filter last names that start with X.
DoCmd.ApplyFilter "", "[tblTrespass]![strLastName] Like ""X*"""
Code for Z (it works)
If (alphabar = 26) Then
' Filter last names that start with Z.
DoCmd.ApplyFilter "", "[tblTrespass]![strLastName] Like ""Z*"""
If (alphabar = 27) Then
' Show all names.
If (RecordsetClone.RecordCount > 0) Then
' If records are returned for the selected letter, go to the AlphaBar control.
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