BuildCriteria builds Frustration (1 Viewer)

NauticalGent

Ignore List Poster Boy
Local time
Today, 07:40
Joined
Apr 27, 2015
Messages
6,280
Hello folks,

I am using an Option Group to open and filter another form. I am trying to use BuildCriteria to accomplish this, but I am not having luck. Here is my code:

Private Sub Frame0_AfterUpdate()
Dim strCriteria as String
strCriteria = BuildCriteria("[FLT_ID]", dbText, "5")

Select Case
Case 1
If DCount("*","qryMyQuery") > 0 Then
DoCmd.OpenForm "frmMyForm",,strCriteria
Me.Filter = strCriteria
Me.Filter = True
Else
MsgBox "No Records to Display":
End If

Case 2....

I get a clean Compile and all that, and the form opens with do errors. However no records are getting filtered.

Can anyone tell me what it is I am doing wrong?
TIA
 

sneuberg

AWF VIP
Local time
Today, 04:40
Joined
Oct 17, 2014
Messages
3,506
One thing is that

Me.Filter = True

should be

Me.FilterOn = True
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 07:40
Joined
Apr 27, 2015
Messages
6,280
Typo...I was hand-jamming from a system that will not allow me to cut and paste.
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 07:40
Joined
Apr 27, 2015
Messages
6,280
To make things more clear, my ultimate goal is to filter a form based on two Option Groups. I was going to use one for starters just to see how it worked. I was able to use the Case method using individual queries, but that is too inefficient for me to stomach.

Open to any and all suggestions.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 11:40
Joined
Jul 9, 2003
Messages
16,244
I have compiled three sets of YouTube videos (Play Lists) which demonstrate how to build your own search form from scratch...

If you watch the last set of videos first:- Microsoft Access - Easy Search Criteria

You will see an example with option groups.

The three play lists cover the subject of a search form from a simple example to a reasonably sophisticated solution. You should be able to find a level that suits you.

MS Access - Building Search Criteria
MS Access - Building Advanced Search Criteria
Microsoft Access - Easy Search Criteria

I think the first playlist should cover what you want, but you can take it much further if you feel the need.


Sent from my SM-G925F using Tapatalk
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 07:40
Joined
Apr 27, 2015
Messages
6,280
Wish I could press that "Thanks" button multiple times... Haven't watched them yet, but I got a feeling my answer is in there!

Grazie mille!!
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 11:40
Joined
Jul 9, 2003
Messages
16,244
My intention is to create a course based on those playlists to teach VBA so if you do decide to use them I will help you the best I can...

Sent from my SM-G925F using Tapatalk
 

Users who are viewing this thread

Top Bottom