Microsoft Access
--
Questions
--
Followers
Top Experts
On Form A I have several categories to check Category A, B, C that is base on yes/no. I want to make sure when I check Category A, just A shows on Form B. If left on unchecked then all categories show.
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
what do you meanI don't know what you've named your controls nor what fields (names) are connected to the controls. Â I don't know if you have checkbox controls that aren't related to filtering.
I just want to know a simple a vba expressionYou're asking for VBA code. Â This isn't going to be something as simple as an expression. Â Any VBA code will need to iterate controls and construct all, or part of, a WHERE clause.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
In design mode, press F4 and find properties from the resulting dialog.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Sent you a private message, maybe you can review my code...Thanks

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
Private Sub Refilter()
Dim strFilterString As String
'BUILD THE FILTER STRING:
If Form_002_Criteria.CKNFixer = True Then
strFilterString = strFilterString & " OR [NFixer] = True"
End If
If Form_002_Criteria.CkSun = True Then
strFilterString = strFilterString & " OR [TolerantSun] = True"
End If
'REMOVE LEADING " OR " ON FILTER STRING:
If strFilterString <> "" Then strFilterString = Mid(strFilterString, 5)
'APPLY FILTER STRING TO Form_003_Species.ListSciName:
If strFilterString <> "" Then
Form_003_Species.Filter = strFilterString
Form_003_Species.FilterOn = True
Else
Form_003_Species.Filter = ""
Form_003_Species.FilterOn = False
End If
End Sub
What is your filter string look like? Â put a breakpoint on "If strFilterString <>Â "" Then" and see what the value of strFilterString is. Â If that doesn't make it obvious, then we could have any number of issues.
CKNFixer and  CkSun are both names of checkbox controls on your form.  See how simple this could have been?  No need for private messages.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
I am new to learning Ms access.
Private Sub Command4_Click()
Dim strFilterString As String
If Me.chk1 = True Then
strFilterString = strFilterString & " OR [FolderSizeDenied]=True"
End If
If Me.chk2 = True Then
strFilterString = strFilterString & " OR [SubfoldersDenied]=True"
End If
If strFilterString <> "" Then strFilterString = Mid(strFilterString, 5)
If strFilterString <> "" Then
Forms("CheckBoxFilterTest2").Filter = strFilterString
Forms("CheckBoxFilterTest2").FilterOn = True
Else
Forms("CheckBoxFilterTest2").Filter = ""
Forms("CheckBoxFilterTest2").FilterOn = False
End If
Forms("CheckBoxFilterTest2").Requery
End Sub

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
MsgBox strFilterString
 We haven't changed the Filter property of the form yet at this point.
Thank you, I sent you the file to get a better look at, I am new to access.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Since I don't see any other code affecting the listbox or its rowsource, the code is a changed to set the listbox rowsource instead of the form's filter property.
If strFilterString <> "" Then
Forms("003_Species").ListSciName.RowSource = "SELECT * FROM [qSciName] WHERE " & strFilterString
Else
Forms("003_Species").ListSciName.RowSource = "qSciName"
End If
thanks...I hope it is correct now
Private Sub BtnPotential_Click()
Dim strFilterString As String
If Me.CKNFixer = True Then
strFilterString = strFilterString & " OR [NFixer] = True"
End If
If Me.CkSun = True Then
strFilterString = strFilterString & " OR [TolerantSun] = True"
End If
If strFilterString <> "" Then strFilterString = Mid(strFilterString, 5)
If strFilterString <> "" Then
Forms("003_Species").ListSciName.RowSource = "SELECT * FROM [qSciName] WHERE " & strFilterString
Else
Forms("003_Species").ListSciName.RowSource = "qSciName"
If strFilterString <> "" Then
Forms("003_Species.ListSciName").Filter = strFilterString
Forms("003_Species.ListSciName").FilterOn = True
Else
Forms("003_Species.ListSciName").Filter = ""
Forms("003_Species.ListSciName") = False
End If
Forms("003_Species.ListSciName").Requery
End Sub

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
If strFilterString <> "" Then
Forms("003_Species.ListSciName").Filter = strFilterString
Forms("003_Species.ListSciName").FilterOn = True
Else
Forms("003_Species.ListSciName").Filter = ""
Forms("003_Species.ListSciName") = False
End If
Forms("003_Species.ListSciName").Requery






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
I've got to go to work now. Â I'll be back tonight.
Private Sub Refilter()
Dim strFilterString As String
'BUILD THE FILTER STRING:
If Forms("002_Criteria").CKNFixer.ControlSource = True Then
strFilterString = strFilterString & " OR Forms!002_Criteria.NFixer = True"
End If
'REMOVE LEADING " OR " ON FILTER STRING:
If strFilterString <> "" Then strFilterString = Mid(strFilterString, 5)
'APPLY FILTER STRING TO 003_Species:
If strFilterString <> "" Then
Forms("003_Species").ListSciName.RowSource = "SELECT * FROM [qSciName] WHERE " & strFilterString
Else
Forms("003_Species").ListSciName.RowSource = "qSciName"
End If
End Sub

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
I just emailed you the file...Thank you
If Forms("002_Criteria").CKNF
    strFilterString = strFilterString & " OR  qSciName.[FieldNameHere]='
End If
I don't know what you're trying to look for in your query by checking a checkbox on form 002.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
If Forms("002_Criteria").CKNFixer.ControlSource = True Then
strFilterString = strFilterString & " OR qSciName.SciName = True"
I have the code typed like this, and still does nothing.
The field [SciName] on your query "qSciName" is a text field and you should be filtering it for something.
Try and describe in your own words what you are wanting to do with the qSciName query data if a checkbox is checked.
pop quiz: What values can a checkbox control have?

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
Please respect my wishYou did not make that 'wish' known in this thread prior to your recent comment. Â That is why I kept asking you to post your database.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
WHERE (([Forms]![002_Criteria].[
AND ((PlantPractices.Plan)=[Fo
AND ((PlantSpecies.AOI)=[Forms
The criteria simply says if the checkbox on the form is checked, then the yes/no field is True (checked or -1) or if the checkbox on the form is unchecked, then the yes/no field is 0 or -1 (False or True)
What is the numeric value of vbChecked?

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
I did the where SQL statement you stated. When I add the other check boxes, it causes the list box to not display the data even when it is unchecked.
Thank you for assisting me :)






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
The sql statement would be in the query of qSciName

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
I forgot to mention that we don't need the code anymore because we are putting the filtering in the query.
The WHERE statement I provided above should work perfectly in the query. Â Replace the WHERE clause in the SQL view of your query with the one above.
Do you know how to copy and paste the WHERE clause above into the SQL view of your qSciName query?
I've got your app working and filtering as you wanted with it. Â Don't the other checkboxes work the same way?






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Thank you again for your help :)
SELECT PlantSpecies.PlantSpeciesID, PlantSpecies.SciName, PlantSpecies.ComName, PlantPractices.PlantRate, PlantPractices.PlantUnit
FROM (Criteria INNER JOIN (ConservationPlan INNER JOIN PlantPractices ON ConservationPlan.PlanNumber = PlantPractices.Plan) ON Criteria.SciName = PlantPractices.SciName) INNER JOIN PlantSpecies ON Criteria.SciName = PlantSpecies.SciName
WHERE (
(([Forms]![002_Criteria].[NFixer])=-1) AND ((Criteria.nfixer)=-1)
AND (([Forms]![002_Criteria].[TolerantSun])=-1) AND ((Criteria.TolerantSun)=-1)
AND (([Forms]![002_Criteria].[TolerantShade])=-1) AND ((Criteria.TolerantShade)=-1)
AND (([Forms]![002_Criteria].[TolerantWind])=-1) AND ((Criteria.TolerantWind)=-1)
AND (([Forms]![002_Criteria].[TolerantSalt])=-1) AND ((Criteria.TolerantSalt)=-1)
AND (([Forms]![002_Criteria].[Pollinator])=-1) AND ((Criteria.Pollinator)=-1)
AND (([Forms]![002_Criteria].[Native])=-1) AND ((PlantSpecies.Native)=-1)
AND (([Forms]![002_Criteria].[Introduce])=-1) AND ((PlantSpecies.introduce)=-1)
AND ((PlantPractices.Plan)=[Forms]![002_Criteria]![cboPlan]) AND ((PlantSpecies.AOI)=[Forms]![001_Selection].[ListAOI]))
OR (
(([Forms]![002_Criteria].[NFixer])=0) AND ((Criteria.nfixer)=-1 Or (Criteria.nfixer)=0)
AND (([Forms]![002_Criteria].[TolerantSun])=0) AND ((Criteria.TolerantSun)=-1 Or (Criteria.TolerantSun)=0)
AND (([Forms]![002_Criteria].[TolerantShade])=0) AND ((Criteria.TolerantShade)=-1 Or (Criteria.TolerantShade)=0)
AND (([Forms]![002_Criteria].[TolerantWind])=0) AND ((Criteria.TolerantWind)=-1 Or (Criteria.TolerantWind)=0)
AND (([Forms]![002_Criteria].[TolerantSalt])=0) AND ((Criteria.TolerantSalt)=-1 Or (Criteria.TolerantSalt)=0)
AND (([Forms]![002_Criteria].[Pollinator])=0) AND ((Criteria.Pollinator)=-1 Or (Criteria.Pollinator)=0)
AND (([Forms]![002_Criteria].[Native])=0) AND ((PlantSpecies.Native)=-1 Or (PlantSpecies.Native)="0")
AND (([Forms]![002_Criteria].[Introduce])=0) AND ((PlantSpecies.introduce)=-1 Or (PlantSpecies.introduce)="0")
AND ((PlantPractices.Plan)=[Forms]![002_Criteria]![cboPlan]) AND ((PlantSpecies.AOI)=[Forms]![001_Selection].[ListAOI]));
If it is, let me know the table.field
Thanks for asking yes is suppose be left out for now, later on I will check that. Same thing for Water and Irrigation.

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
Yuppie, I have to locate the correct and enter data for those three.
SELECT PlantSpecies.PlantSpeciesI
FROM (Criteria INNER JOIN (ConservationPlan INNER JOIN PlantPractices ON ConservationPlan.PlanNumbe
WHERE ((PlantPractices.Plan)=[Fo
AND ((PlantSpecies.AOI)=[Forms
AND (
(([Forms]![002_Criteria].[
AND
(([Forms]![002_Criteria].[
AND
(([Forms]![002_Criteria].[
AND
(([Forms]![002_Criteria].[
AND
(([Forms]![002_Criteria].[
AND
(([Forms]![002_Criteria].[
AND
(([Forms]![002_Criteria].[
);






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
Wish I knew how to add screenshots like you do....






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
You did delete the code on the button click event on form 002, right?

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
Now you see why I like SQL and not the Query Grid crutch. Â The grid re-writes your SQL.
We can use code instead of SQL, if that will make things simpler.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
If I get all records and you get no records with the same file, then that's going to be interesting.....






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
The text box suppose work for example, say there a value of 15 to 80.
if someone enters 20 is 20 >= 15? T or 20 <= 80? T
If someone enters 100 is 100 >= 15? T or is 100 <= 80? F
Sub ListSciNamet()
  'Rain fall range criteria
  If Not "" & Form_002_Criteria.TxtRain.
    BuildFilter sFilter, "(([Criteria].[RainMax]=" & Form_002_Criteria.TxtRain.
  Else
 Â
  End If
 Â
  'Elavation feet
  If Not "" & Form_002_Criteria.TxtElv.V
    BuildFilter sFilter, "(([Criteria].[ElevMax]=" & Form_002_Criteria.TxtElv.V
  Else
 Â
  End If
End Sub

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
If you want to add more filtering, then we are going to have to scrap the filtering in the query SQL and go with a VBA code solution that builds a filter string that we can apply to the listbox query.
I can't write your project for you. Â I'll get the filtering code set for what we have done so far, then we're done once your listbox works.
I'll get that to you tomorrow,
I'm adding the rain fall and elevation criteria, but I have no idea what the first part was:
The text box suppose work for example, say there a value of 15 to 80.
 if someone enters 20 is 20 >= 15? T or 20 <= 80? T
 If someone enters 100 is 100 >= 15? T or is 100 <= 80? F
If that was just a generic question, you'll see how it is done when you get the file from me.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
* The resulting SQL doesn't reference field names in the table, just controls on the form.
* Looks like you are hard-coding the checkbox names, rather than iterate the controls.
* The checkbox controls are bound to fields in the form's recordsource. Â If you click a checkbox, it will change the underlying table.

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
I took the file I sent you and ran it on my virtual machine with WindowsXP and Office 2007 (I don't have O2007 on a Win7 or Win10 machine).
It ran perfectly.
If you are copying code and SQL from the file I sent into your copy of the file, that may be where your issues are coming in - you're missing something.
I'll send a complete list of the changes I made to you via message.
It must be my access.Try reinstalling the version of Access that is failing. Â Also, not all accdb formats are compatible with Access2007.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Microsoft Access
--
Questions
--
Followers
Top Experts
Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.
