I've got this code on a few of my Fields to do Specific searches on those Fields, but for some reason I never noticed this happen before. When I search for on a particular Field that does have what I'm looking for everything is fine, but when it doesn't find anything and I try to get out of the Filter I get this error:
Run-Time Error "3021" No Current Record.
When I debug it brings me to this code:
Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer) Me.Recordset.MoveLast End Sub
With Me.Recordset.MoveLast highlighted.
This is my search code:
Private Sub SearchAirportCodeBtn_Click() Dim S As String
S = InputBox("Please Enter The IATA or IACO Airport Code", "SEARCH For A Specific IATA or IACO Airport Code")
If S = "" Then Exit Sub
Me.Filter = "AirportCode LIKE ""*" & S & "*""" Me.FilterOn = True End Sub
But the First Code is associated with this code:
Private Sub Form_Current() RecCountBx = Me.Recordset.AbsolutePosition + 1 & " of " & Me.Recordset.RecordCount End Sub
Kevin Robertson 15 months ago
How is the first code associated with the code in the Form_Current event (There is no call to it)?
Also, can you please post some screenshots of your Form, the error, your code (with the highlighted line that generated the error) and anything else you feel may be relevant.
Giovanni MirandaOP 15 months ago
Okay,
Here are the Images and the explanation with each Image:
First Image - Current Form I am working with
Second Image - Starting my Search
Third Image - What I'm Searching for, but it's not in the Database
Fourth Image - No results, I Click to remove the Filter (at the bottom)
Fifth Image - Error Box appears
Sixth Image - I Click Debug button
Seventh Image - Yellow area where Debug took me to
and the ONLY way I can get out of the Loop of getting the error again when I try to click the Filter to clear is to Exit the Form itself.
Giovanni MirandaOP 15 months ago
Giovanni MirandaOP 15 months ago
Giovanni MirandaOP 15 months ago
Giovanni MirandaOP 15 months ago
Giovanni MirandaOP 15 months ago
Giovanni MirandaOP 15 months ago
Giovanni MirandaOP 15 months ago
Giovanni MirandaOP 15 months ago
Giovanni MirandaOP 15 months ago
Kevin,
I appreciate you racking your brain out as well in helping me. Just to let you know I took that statement out of my code as it really doesn't seem to affect my record count as to where it's pointing to in my RecCountBx Field that keeps track of the Record I'm on and how many records I have.
Seems my system is fast enough to keep up with the function itself and it isn't lagging behind to give me wrong record number readings at the bottom of the Form. So, I've left it out and everything seems to be working fine now. I appreciate all your help and trying to get this resolved for me.
Fast flights and safe landings!
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
TechHelp.
The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.