Run-Time Error 3709 (1 Viewer)

NauticalGent

Ignore List Poster Boy
Local time
Today, 08:59
Joined
Apr 27, 2015
Messages
6,370
Good morning all,

I have a continuous form that I would like to filter with a combo-box in the forms header.

The combo box is populated with the table's primary field [ID] which is an Autonumber. When I click the caret on the combo box, it provides a list of ID's but when I select one, I get this error message "Run-time error 3709, the search key was not found in any record"

The code is:

Code:
Private Sub Combo 31_AfterUpdate()
If Me.Combo31 & ""<> "" Then
     Me.Filter = "[ID]= '"& Me.Combo31 & "'"
Else
     Me.Filter = ""
End If
Me.FilterOn = True
End Sub

I have googled this issue and tried some of the suggestions, included compacting and repairing the database, but nothing has worked.

Any assistance would be appreciated!
 
Last edited:

JHB

Have been here a while
Local time
Today, 14:59
Joined
Jun 17, 2012
Messages
7,732
...
Private Sub Combo 31_AfterUpdate()
If Me.Combo31 & ""<> "" Then
Me.Filter = "[ID]= '"& Me.Combo31 & "'"
Else
Me.Filter = ""
End If
Me.FilterOn = True
End Sub
What are you attempting to do in the marked code line?
 

GinaWhipp

AWF VIP
Local time
Today, 08:59
Joined
Jun 21, 2011
Messages
5,899
Is *ID* a part of the Recordsource?
 

spikepl

Eledittingent Beliped
Local time
Today, 14:59
Joined
Nov 3, 2010
Messages
6,142
table's primary field [ID] which is an Autonumber.


Me.Filter = "[ID]= '"& Me.Combo31 & "'"
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 08:59
Joined
Apr 27, 2015
Messages
6,370
JHB, I am trying to filter the form to just that one record if a user needs to. Normally the form would have about 200+ records that meet the record set.

GinaWhipp, ID is part of the record source.

Spikepl, good catch and I was hoping that was the mistake. However, when I looked at the code, I do in fact have the single quotes where you have them, I just didn't copy the code over correctly. The code is on a classified system so cut and paste is not an option.
 

JHB

Have been here a while
Local time
Today, 14:59
Joined
Jun 17, 2012
Messages
7,732
I would think it should be:
Code:
If Me.Combo31 <> "" Then
and not
If Me.Combo31[B][COLOR=Red] & ""[/COLOR][/B]<> "" Then
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 08:59
Joined
Apr 27, 2015
Messages
6,370
Actually, I think Spikepl was trying to tell me that since my field is a number, the single quotes within the double quotes are not needed. I had to leave work early to attend to an urgent matter, but I will try this first thing in the morning. More to follow...
 

jdraw

Super Moderator
Staff member
Local time
Today, 08:59
Joined
Jan 23, 2006
Messages
15,386
PMFJI,
You have understood spike's post completely.
 

jdraw

Super Moderator
Staff member
Local time
Today, 08:59
Joined
Jan 23, 2006
Messages
15,386
Pardon Me For Jumping In

I didn't know if spike was about to answer, and didn't want to intercede.

quotes around strings/text 'this is a string'
octothorpes/hashtag around dates #21/03/2015#
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 08:59
Joined
Apr 27, 2015
Messages
6,370
Spikepl's input was spot-on! Gotta say, I was a little put out at first because I felt it was a little cryptic. But I with my feeble brain being forced to suss out why he/she chose to use the red font in strategic places, I will never forget it, that's for sure.

Jdraw, I issue you a full pardon for "jumping in", and thanks to you, I now have a forth alternative for the # sign.

In all seriousness, thanks to all for chiming in, it's sites like this that makes all the "head banging" worth it....
 

vbaInet

AWF VIP
Local time
Today, 13:59
Joined
Jan 22, 2010
Messages
26,374
But I with my feeble brain being forced to suss out why he/she chose to use the red font in strategic places, I will never forget it, that's for sure.
Definitely she :D

By the way, if you're setting a filter string to "" turn the filter off.
 

Users who are viewing this thread

Top Bottom