Error 2115 from Search Box after Changes

carnealse

Registered User.
Local time
Today, 08:29
Joined
Jun 17, 2014
Messages
15
I have an unbound text box with a search button running a macro "applyfilter," and in the "Where Condition =" I have the following;

[lastname] & [firstname] & [rate] & [rank] & [notes] & [workarea] & [badge] Like "*" & [Forms]![N91 RECORDS]![Text128] & "*"

Now, in the form, if I open it up I can search all day. However, if I make one change to any data in the form and then go to search I receive the "beforeupdate" error 2115, UNLESS, I first hit the "Save" button on my form. Then the search function will return no errors until I make another change and don't hit the save button first.
I also get the run-time error 2115 for the "Clear Filter" running this code under the same conditions;

Private Sub Command197_Click()
DoCmd.ShowAllRecords
Me.Text128 = ""
End Sub

What can I do about this so that the user can make a change on a form he/she just searched for and then clear the filter, and or do a new search without this error popping up every time without hitting the save button after every little change?
 
I don't use Macros but any reason why you don't use a search combo box instead?
That said, I'm sure a OnChangeEvent or a simple Requery might help.
 
Well, using a combo box in this instance would not be ideal. The records are changed constantly and there are 83 records and counting.
These are student records for Navy personnel for training and are always coming in so to scroll down a list to pick a student is not my first choice.

Where do you suggest the onchange or requery go? I did just try the requery on the ondatachange event macro for the form and still had the same error.

The reason for macro uses...Im quite new at this and I just learned how to dim variables haha. So VBA language is not a fluent one for me yet.
 
Records changing has nothing to do with it. A search combo is based on a query and runs with the latest data.
 
Maybe there is a disconnect between what I am saying and what you think I mean.
The records changing has everything to do with it because only when a record changes will the search function return the 2115 when a new search is attempted or the clear filter is attempted, unless the save button is hit first. That is why I mentioned records change constantly.
I am not going to use the combo for the mere reason I am not going to search a combo list of 83...well add in 47 more for this week...and then more next week, then the next.
I have classed up students who are on the list and a report that filters them out to review only them, however they will be on that list as well since it is a continuous form but we mainly deal with current students on holding status, not so much the classed up ones.
Roughly 1500 students a year pass through so you can see that list will be too long now and more so over time for a combo. Granted I will archive the classed up students quarterly, but the list would still be too long. That is why I opted for a text box.
It would appear from your comments that I should learn more about VBA than using macro for more control, so that is what I will do. Including trying to figure out how to properly use what you suggested before with the onchange event with a requery.
Hopefully I can get it to work error free that way. Thanks.
 
In that case I would suggest a check if the record has been saved before allowing a new search. Example Below.
If Me.Dirty = True Then
'Do Something

HTH
 
Well I figured it out. I did play around with the Dirty as well. I just wasn't sure exactly what I was doing with it. I just saw your reply and I think that could do it as well.
This is what I used to force a save after using the search text box eliminating the error;

Private Sub Form_AfterUpdate()

RunCommand acCmdSaveRecord

End Sub
 
Which is what I alluded to in the above. Glad you got it sorted out.
Good luck With Your Project!
 

Users who are viewing this thread

Back
Top Bottom