Filtering help! 07' (1 Viewer)

JBurlison

Registered User.
Local time
Today, 14:54
Joined
Mar 14, 2008
Messages
172
Ok im Reallllllllllyyyyy new to programming in general and in trying to get a
search working that as 7 different criteria on a form, all criteria are
selected via dropdown and are unbound. i want to open a multiple items form
based on a query that i made and apply the 7 criteria and filter the form
from there i would like the ability to print the search Via a report i have
made. now thusfar i have this and it dose not work at all and i am really
need help lol:


Private Sub Command28_Click()

DoCmd.OpenForm "Main Inventory Advanced Search"

If IsNull([Forms]![Advanced Inventorysearch Beta]![User]) Or "" Then


Else

DoCmd.ApplyFilter 'cannot figure this function out for the life of me.

End If



End Sub

Now the form i want to apply the filter to is "Advanced inventory Search"
and the form the Critera is on is "Advanced Inventorysearch Beta". tried
doint this via macro but someone told me i cant because i would not be able
to print the results on the report i want but even after i figure out the
whole "apply Filter" thing with multiple criteria couldent i just point the
reports fields to this form or would i have to save the search as a quary
somehow?
 

DrSnuggles

Well the hell is Hudson??
Local time
Today, 19:54
Joined
Sep 14, 2004
Messages
117
Before you open the form you should save all the filter criteria in a string.
On the Docmd.Openform command you can pass the string in the Wherecondition.

It's just one way of doing it . . .
 

JBurlison

Registered User.
Local time
Today, 14:54
Joined
Mar 14, 2008
Messages
172
Ahhh ic ic i was doing it backwords. Thanks man! also can someone explain IsNull to me, like is

Code:
IsNull (<Expression>) or ""

Wouls this be a valid use of isnull?
 

boblarson

Smeghead
Local time
Today, 11:54
Joined
Jan 12, 2001
Messages
32,059
Ahhh ic ic i was doing it backwords. Thanks man! also can someone explain IsNull to me, like is

Code:
IsNull (<Expression>) or ""

Wouls this be a valid use of isnull?

A better way would be:

Code:
If Len([YourField] & "") = 0 Then

That checks for both nulls AND zero length strings.
 

boblarson

Smeghead
Local time
Today, 11:54
Joined
Jan 12, 2001
Messages
32,059
No, the length of the value of the control and the zero length string together. If the length is zero, then it must be a null or zero length string.
 

JBurlison

Registered User.
Local time
Today, 14:54
Joined
Mar 14, 2008
Messages
172
Ahh Ic Ic. to quote Dr Snuggles

"Before you open the form you should save all the filter criteria in a string.
On the Docmd.Openform command you can pass the string in the Wherecondition.

It's just one way of doing it . . ."

would this be something like what he (or you) are talking about, im still really new to programming trying to get the lingo down, and the general application of the basics.

Code:
Private Sub Command28_Click()
    
Dim strFilter As String

If Len([Location] & "") = 0 Then

    Else
    strFilter = "[Location] = " & strfilter
End If


If Len(strFilter) > 0 Then
DoCmd.OpenForm Main_Inventory_Advanced_Search
Filter = strFilter
FilterOn = True
Requery
DoCmd.Save acQuery, "IR"

Else
DoCmd.OpenForm Main_Inventory_Advanced_Search
FilterOn = False
End If


If Len(strFilter) > 0 Then would this be an appropriate use of Len if i had added in multiple arguments?

Also would my arguments come out valid (would the code work?)

p.s. sry bob tried adding more to your rep but you recently helped me with my password issues and dlookup! you the man!
 

Users who are viewing this thread

Top Bottom