VBA Microsoft Access Check boxes not filtering data











up vote
0
down vote

favorite












On Form 002_Criteria, I have a checkbox. Currently it does nothing, and I would like for these check boxes to display related data under that field that is checked in a List Box on Form 003_Species. The list box is rowsource is a query know as qSciName. It currently has all the scientific name showing in the list box. The query has multiple tables such as PlantSpecies with field names like PlantSpeciesID, SciName, ComName and another table know as Criteria has the SciName criteria.



I tried the following coding and it did not filter my the results in the list box. I also tried listing the fields in the query and using the criteria to point the check box. When I did this and the more fields I add, it would subtract the Scientific Names until nothing displayed. What can you do to get my code to work properly?



Thank you for help :)



Private Sub Refilter()

Dim strFilterString As String

'BUILD THE FILTER STRING:
If Forms("002_Criteria").CKNFixer = True Then
strFilterString = strFilterString & " OR NFixer ='True'"
End If

If Forms("002_Criteria").CkSun = True Then
strFilterString = strFilterString & " OR TolerantSun ='True'"
End If

If Forms("002_Criteria").CKShade = True Then
strFilterString = strFilterString & " OR TolerantShade ='True'"
End If

If Forms("002_Criteria").CKWind = True Then
strFilterString = strFilterString & " OR TolerantWind ='True'"
End If

If Forms("002_Criteria").CkSalt = True Then
strFilterString = strFilterString & " OR TolerantSalt ='True'"
End If

If Forms("002_Criteria").CkPollinator = True Then
strFilterString = strFilterString & " OR Pollinator ='True'"
End If

If Forms("002_Criteria").CkNative = True Then
strFilterString = strFilterString & " OR Native ='True'"
End If

If Forms("002_Criteria").CKIntroduce = True Then
strFilterString = strFilterString & " OR introduce ='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









share|improve this question


















  • 1




    Fields like TolerantShade are a string or Yes/No? If Yes/No, then remove single quotes.
    – Sergey S.
    Nov 20 at 3:22










  • Sergey S. They are Yes/No, I did remove the single and vba still did nothing with filtering the list box.
    – Tim
    Nov 20 at 5:06






  • 1




    Does your final query, which you set to the RowSource property work well, if you run it by hand, for example by creating a new query object?
    – Unhandled Exception
    Nov 20 at 7:59






  • 1




    Are you sure about OR? Maybe you need to use AND instead?
    – Sergey S.
    Nov 20 at 8:01










  • I will try replace or with and, I dont think it will make a difference at all as should have been doing something by now.
    – Tim
    Nov 20 at 16:47















up vote
0
down vote

favorite












On Form 002_Criteria, I have a checkbox. Currently it does nothing, and I would like for these check boxes to display related data under that field that is checked in a List Box on Form 003_Species. The list box is rowsource is a query know as qSciName. It currently has all the scientific name showing in the list box. The query has multiple tables such as PlantSpecies with field names like PlantSpeciesID, SciName, ComName and another table know as Criteria has the SciName criteria.



I tried the following coding and it did not filter my the results in the list box. I also tried listing the fields in the query and using the criteria to point the check box. When I did this and the more fields I add, it would subtract the Scientific Names until nothing displayed. What can you do to get my code to work properly?



Thank you for help :)



Private Sub Refilter()

Dim strFilterString As String

'BUILD THE FILTER STRING:
If Forms("002_Criteria").CKNFixer = True Then
strFilterString = strFilterString & " OR NFixer ='True'"
End If

If Forms("002_Criteria").CkSun = True Then
strFilterString = strFilterString & " OR TolerantSun ='True'"
End If

If Forms("002_Criteria").CKShade = True Then
strFilterString = strFilterString & " OR TolerantShade ='True'"
End If

If Forms("002_Criteria").CKWind = True Then
strFilterString = strFilterString & " OR TolerantWind ='True'"
End If

If Forms("002_Criteria").CkSalt = True Then
strFilterString = strFilterString & " OR TolerantSalt ='True'"
End If

If Forms("002_Criteria").CkPollinator = True Then
strFilterString = strFilterString & " OR Pollinator ='True'"
End If

If Forms("002_Criteria").CkNative = True Then
strFilterString = strFilterString & " OR Native ='True'"
End If

If Forms("002_Criteria").CKIntroduce = True Then
strFilterString = strFilterString & " OR introduce ='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









share|improve this question


















  • 1




    Fields like TolerantShade are a string or Yes/No? If Yes/No, then remove single quotes.
    – Sergey S.
    Nov 20 at 3:22










  • Sergey S. They are Yes/No, I did remove the single and vba still did nothing with filtering the list box.
    – Tim
    Nov 20 at 5:06






  • 1




    Does your final query, which you set to the RowSource property work well, if you run it by hand, for example by creating a new query object?
    – Unhandled Exception
    Nov 20 at 7:59






  • 1




    Are you sure about OR? Maybe you need to use AND instead?
    – Sergey S.
    Nov 20 at 8:01










  • I will try replace or with and, I dont think it will make a difference at all as should have been doing something by now.
    – Tim
    Nov 20 at 16:47













up vote
0
down vote

favorite









up vote
0
down vote

favorite











On Form 002_Criteria, I have a checkbox. Currently it does nothing, and I would like for these check boxes to display related data under that field that is checked in a List Box on Form 003_Species. The list box is rowsource is a query know as qSciName. It currently has all the scientific name showing in the list box. The query has multiple tables such as PlantSpecies with field names like PlantSpeciesID, SciName, ComName and another table know as Criteria has the SciName criteria.



I tried the following coding and it did not filter my the results in the list box. I also tried listing the fields in the query and using the criteria to point the check box. When I did this and the more fields I add, it would subtract the Scientific Names until nothing displayed. What can you do to get my code to work properly?



Thank you for help :)



Private Sub Refilter()

Dim strFilterString As String

'BUILD THE FILTER STRING:
If Forms("002_Criteria").CKNFixer = True Then
strFilterString = strFilterString & " OR NFixer ='True'"
End If

If Forms("002_Criteria").CkSun = True Then
strFilterString = strFilterString & " OR TolerantSun ='True'"
End If

If Forms("002_Criteria").CKShade = True Then
strFilterString = strFilterString & " OR TolerantShade ='True'"
End If

If Forms("002_Criteria").CKWind = True Then
strFilterString = strFilterString & " OR TolerantWind ='True'"
End If

If Forms("002_Criteria").CkSalt = True Then
strFilterString = strFilterString & " OR TolerantSalt ='True'"
End If

If Forms("002_Criteria").CkPollinator = True Then
strFilterString = strFilterString & " OR Pollinator ='True'"
End If

If Forms("002_Criteria").CkNative = True Then
strFilterString = strFilterString & " OR Native ='True'"
End If

If Forms("002_Criteria").CKIntroduce = True Then
strFilterString = strFilterString & " OR introduce ='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









share|improve this question













On Form 002_Criteria, I have a checkbox. Currently it does nothing, and I would like for these check boxes to display related data under that field that is checked in a List Box on Form 003_Species. The list box is rowsource is a query know as qSciName. It currently has all the scientific name showing in the list box. The query has multiple tables such as PlantSpecies with field names like PlantSpeciesID, SciName, ComName and another table know as Criteria has the SciName criteria.



I tried the following coding and it did not filter my the results in the list box. I also tried listing the fields in the query and using the criteria to point the check box. When I did this and the more fields I add, it would subtract the Scientific Names until nothing displayed. What can you do to get my code to work properly?



Thank you for help :)



Private Sub Refilter()

Dim strFilterString As String

'BUILD THE FILTER STRING:
If Forms("002_Criteria").CKNFixer = True Then
strFilterString = strFilterString & " OR NFixer ='True'"
End If

If Forms("002_Criteria").CkSun = True Then
strFilterString = strFilterString & " OR TolerantSun ='True'"
End If

If Forms("002_Criteria").CKShade = True Then
strFilterString = strFilterString & " OR TolerantShade ='True'"
End If

If Forms("002_Criteria").CKWind = True Then
strFilterString = strFilterString & " OR TolerantWind ='True'"
End If

If Forms("002_Criteria").CkSalt = True Then
strFilterString = strFilterString & " OR TolerantSalt ='True'"
End If

If Forms("002_Criteria").CkPollinator = True Then
strFilterString = strFilterString & " OR Pollinator ='True'"
End If

If Forms("002_Criteria").CkNative = True Then
strFilterString = strFilterString & " OR Native ='True'"
End If

If Forms("002_Criteria").CKIntroduce = True Then
strFilterString = strFilterString & " OR introduce ='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






ms-access access-vba






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 at 3:06









Tim

11




11








  • 1




    Fields like TolerantShade are a string or Yes/No? If Yes/No, then remove single quotes.
    – Sergey S.
    Nov 20 at 3:22










  • Sergey S. They are Yes/No, I did remove the single and vba still did nothing with filtering the list box.
    – Tim
    Nov 20 at 5:06






  • 1




    Does your final query, which you set to the RowSource property work well, if you run it by hand, for example by creating a new query object?
    – Unhandled Exception
    Nov 20 at 7:59






  • 1




    Are you sure about OR? Maybe you need to use AND instead?
    – Sergey S.
    Nov 20 at 8:01










  • I will try replace or with and, I dont think it will make a difference at all as should have been doing something by now.
    – Tim
    Nov 20 at 16:47














  • 1




    Fields like TolerantShade are a string or Yes/No? If Yes/No, then remove single quotes.
    – Sergey S.
    Nov 20 at 3:22










  • Sergey S. They are Yes/No, I did remove the single and vba still did nothing with filtering the list box.
    – Tim
    Nov 20 at 5:06






  • 1




    Does your final query, which you set to the RowSource property work well, if you run it by hand, for example by creating a new query object?
    – Unhandled Exception
    Nov 20 at 7:59






  • 1




    Are you sure about OR? Maybe you need to use AND instead?
    – Sergey S.
    Nov 20 at 8:01










  • I will try replace or with and, I dont think it will make a difference at all as should have been doing something by now.
    – Tim
    Nov 20 at 16:47








1




1




Fields like TolerantShade are a string or Yes/No? If Yes/No, then remove single quotes.
– Sergey S.
Nov 20 at 3:22




Fields like TolerantShade are a string or Yes/No? If Yes/No, then remove single quotes.
– Sergey S.
Nov 20 at 3:22












Sergey S. They are Yes/No, I did remove the single and vba still did nothing with filtering the list box.
– Tim
Nov 20 at 5:06




Sergey S. They are Yes/No, I did remove the single and vba still did nothing with filtering the list box.
– Tim
Nov 20 at 5:06




1




1




Does your final query, which you set to the RowSource property work well, if you run it by hand, for example by creating a new query object?
– Unhandled Exception
Nov 20 at 7:59




Does your final query, which you set to the RowSource property work well, if you run it by hand, for example by creating a new query object?
– Unhandled Exception
Nov 20 at 7:59




1




1




Are you sure about OR? Maybe you need to use AND instead?
– Sergey S.
Nov 20 at 8:01




Are you sure about OR? Maybe you need to use AND instead?
– Sergey S.
Nov 20 at 8:01












I will try replace or with and, I dont think it will make a difference at all as should have been doing something by now.
– Tim
Nov 20 at 16:47




I will try replace or with and, I dont think it will make a difference at all as should have been doing something by now.
– Tim
Nov 20 at 16:47

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53385633%2fvba-microsoft-access-check-boxes-not-filtering-data%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53385633%2fvba-microsoft-access-check-boxes-not-filtering-data%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Wiesbaden

Marschland

Dieringhausen