Solved Very weird behavior- Error '3709': The search key not found in any record (1 Viewer)

Babycat

Member
Local time
Today, 23:04
Joined
Mar 31, 2020
Messages
275
Dear everyone

I have been struggling for 3 days to debug but only narrow down some clues...
I have a mainform and a continous subform, they act like split form.

Main form has button to filter out records on subform, and when user click on a record in subform the main form will show current record detail information.
It works fine when no filter applied on subform.

Mainform.PNG

When applying a filter (type "ABC" in search box), subform's records are filterd out. However when I click on a record on subform, it will introduce error #3709
Error 3709.PNG

I have narrowed down the causes and find it causes by following code in form's filter
Code:
        wildcardstr = " like '*" & str & "*') "
        Strfilter = "(VshortName" & wildcardstr & "OR (VFullName" & wildcardstr _
                    & "OR (Country" & wildcardstr & "OR (ContactName" & wildcardstr _
                    & "OR (ROCNumber" & wildcardstr & "OR (Note" & wildcardstr

IF I make less criteria such as
Code:
        wildcardstr = " like '*" & str & "*') "
        Strfilter = "(VshortName" & wildcardstr & "OR (VFullName" & wildcardstr _
                    & "OR (ContactName" & wildcardstr
then I see It works again.

I attached BD for your kind help.
I am too much exhausted :))
 

Attachments

  • DB_post.zip
    2.8 MB · Views: 61
Last edited:

mike60smart

Registered User.
Local time
Today, 17:04
Joined
Aug 6, 2017
Messages
1,912
Hi
I cannot replicate the error/ When I click in a record in the Subform it displays that specific record selected.

I do however query why you need a subform when you only have 1 Table.
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:04
Joined
Sep 21, 2011
Messages
14,311
Have you actually tried and debug.print the filter?
 

Babycat

Member
Local time
Today, 23:04
Joined
Mar 31, 2020
Messages
275
Hi
I cannot replicate the error/ When I click in a record in the Subform it displays that specific record selected.

I do however query why you need a subform when you only have 1 Table.
Please apply type "ABC" in the search box first, then you click on #2, #3 record of filtered result.
 

Babycat

Member
Local time
Today, 23:04
Joined
Mar 31, 2020
Messages
275
Have you actually tried and debug.print the filter?
Yes, I tried it. I found that assigning bookmark on mainform causes subform's on-current event fires. That's why I said it is very strange/weird behavior.
A question is, why does it not happen when reducing filter criteria string...?
 

Babycat

Member
Local time
Today, 23:04
Joined
Mar 31, 2020
Messages
275
Hi
That is exactly what I did. No error.
Oh, sorry the attached file was with "short-criteria fillter string". That is why no error.
I have re-attached the correct DB file . Please help to take a look again
 

ebs17

Well-known member
Local time
Today, 18:04
Joined
Feb 7, 2020
Messages
1,949
Code:
Strfilter = "(VshortName" & wildcardstr & "OR (VFullName" & wildcardstr _
                    & "OR (Country" & wildcardstr & "OR (ContactName" & wildcardstr _
                    & "OR (ROCNumber" & wildcardstr & "OR (Note" & wildcardstr
There should be a space before each OR.
 

Babycat

Member
Local time
Today, 23:04
Joined
Mar 31, 2020
Messages
275
There should be a space before each OR.
Code:
wildcardstr = " like '*" & str & "*') "
The wildcardstr is with a SPACE at its end, so it is OK
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 12:04
Joined
May 21, 2018
Messages
8,533
There is something really strange. To demonstrate i put record selectors back and a message box on the current event. Filter the list then click on a record. It moves back to the first record twice. I cannot figure out. There must be something linked I do not see, because the code should not do that.

I can fix this by modifying the code, but I think you could try rebuilding the form.
 

Attachments

  • MyParts_postV1.accdb
    3.3 MB · Views: 60

Gasman

Enthusiastic Amateur
Local time
Today, 17:04
Joined
Sep 21, 2011
Messages
14,311
Code:
wildcardstr = " like '*" & str & "*') "
The wildcardstr is with a SPACE at its end, so it is OK
Yes, nothing like making it harder to read. :(
Putting the space at the start of each concatenated line, would remove the need to scroll to the end of each line.
 

Babycat

Member
Local time
Today, 23:04
Joined
Mar 31, 2020
Messages
275
There is something really strange. To demonstrate i put record selectors back and a message box on the current event. Filter the list then click on a record. It moves back to the first record twice. I cannot figure out. There must be something linked I do not see, because the code should not do that.

I can fix this by modifying the code, but I think you could try rebuilding the form.
Hi MajP.

The attached db is already fresh-build. I thought my form was corrupt but rebuid it did not help.
May you please digout further from clue that the error does not happen with short-criteria filter string?
 

Babycat

Member
Local time
Today, 23:04
Joined
Mar 31, 2020
Messages
275
Yes, nothing like making it harder to read. :(
Putting the space at the start of each concatenated line, would remove the need to scroll to the end of each line.
Sorry about that, it costs nothing with sapce before "OR"... but this is cut-down version I did not have must time to make it clearer
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 12:04
Joined
May 21, 2018
Messages
8,533
This thing is acting so bizarre i cannot figure it out. I can no longer modify it. At this point it is a waste of time to look at it. I could rebuild from scratch faster. I cannot locate what is happening.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 12:04
Joined
May 21, 2018
Messages
8,533
My first guess is the whole thing is corrupted, unless there is just something I am not seeing.
 

Josef P.

Well-known member
Local time
Today, 18:04
Joined
Feb 2, 2023
Messages
827
Try this:
Set RecordSource instead of Filter:
Code:
Private Sub User_VendorsFnameFilterParameter(str As String)

   Dim SQLfilter As String
   Dim SelectSql As String

   SelectSql = "select * from Q_QinfoVendor_Source"
   If Len(str) > 0 Then
      SQLfilter = User_VendorsQinfoFilterString(str)
      SelectSql = SelectSql & " where " & SQLfilter
   End If

   With Me.SubFrmQInfo
      .Form.RecordSource = SelectSql
      .LinkChildFields = vbNullString
      .LinkMasterFields = vbNullString
   End With

End Sub

The better solution would be to use an unbound main form with 2 subforms - 1 subform with the list and 1 subform with the detail data.
 

Babycat

Member
Local time
Today, 23:04
Joined
Mar 31, 2020
Messages
275
My first guess is the whole thing is corrupted, unless there is just something I am not seeing.
I was guesting same then I build forms from scratch but same error. Please build the form at your side. Hope you can re-use my data, i suppect the local language characters might make filter work improperly... if so it is my nightmare
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 12:04
Joined
May 21, 2018
Messages
8,533
I will take a look but the weird behavior seems unrelated to the code.
 

Babycat

Member
Local time
Today, 23:04
Joined
Mar 31, 2020
Messages
275
Dear all.

Solved.

With your advices, i followed and found that the subform record source was not table TBLVendor but from query Q_QinfoVendor_Source.
And in Q_QinfoVendor_Source, there are no field names: Country and ROCNumber.
Access introduces no meaningful msg in that case:

Error '3709': The search key not found in any record​


From Josef P. advice, I tried with recordsource, manually run the record source string and now access asked me Country and ROCNumber name....
 

Josef P.

Well-known member
Local time
Today, 18:04
Joined
Feb 2, 2023
Messages
827
... especially, the message comes only when changing the record in the subform and not when filtering.
There are situations where one must not ask why.
 

Users who are viewing this thread

Top Bottom