VBA script (2 Viewers)

niallmc

Old Timer
Supporter
Contributor
Joined
Jun 13, 2002
Messages
1,794
Solutions
1
Location
Dublin
Website
www.hopecollectiveireland.com
I've been working on this for a few days with no joy. I have a vba form with 3 combo boxes. I am trying to do a filter for search purposes. The filter works fine if one field or ALL fileds are input. I'd like to search on ONE or ALL filelds. Any suggestions for what to do?

Here is my code
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmOpen"
stLinkCriteria = "[Code1]=" & "'" & Me![Code1] & "'" & " AND
[Code2]=" & "'" & Me![Code2] & "'"

DoCmd.OpenForm stDocName, , , stLinkCriteria

Thanks
Niall
 
You could make them active/inactive with a checkbox, and then check to see if they've been used by going

if chkCombo1
then strQuery = strQuery & txtCombo1
end if

basically (no pun intended) make a string (strQuery) which will eventually become your query, and concatenate the search parameters (from txtCombo1) onto it if the input box has been used, then concatenate strQuery onto the actual search string.
I did this ages ago to use a load of combo/dropdown/text fields to query a DB, and it worked beautifully. Dunno if that's exactly what you're after.
 
You could make them active/inactive with a checkbox, and then check to see if they've been used by going

if chkCombo1
then strQuery = strQuery & txtCombo1
end if

basically (no pun intended) make a string (strQuery) which will eventually become your query, and concatenate the search parameters (from txtCombo1) onto it if the input box has been used, then concatenate strQuery onto the actual search string.
I did this ages ago to use a load of combo/dropdown/text fields to query a DB, and it worked beautifully. Dunno if that's exactly what you're after.
I appreciate that, I'll give it a bash tomorrow
 

Users who are viewing this thread

Activity
So far there's no one here
Old Thread: Hello . There have been no replies in this thread for 365 days.
Content in this thread may no longer be relevant.
Perhaps it would be better to start a new thread instead.

21 Day Calendar

Fixity/Meabh McKenna/Black Coral
Bello Bar
Portobello Harbour, Saint Kevin's, Dublin, Ireland
Meljoann with special guest Persona
The Workman's Cellar
8 Essex St E, Temple Bar, Dublin, D02 HT44, Ireland

Support thumped.com

Support thumped.com and upgrade your account

Upgrade your account now to disable all ads...

Upgrade now

Latest threads

Latest Activity

Loading…
Back
Top