Re: How do I set the default value so that it includes all values?
- From: sept2006 <sept2006@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 22 Aug 2006 07:43:02 -0700
My programming experience in Acess is very limited. Is there a way to do it
w/o writing in SQL or Visual Basic? I can probably do a little VB, but not
SQL as far as I know.
"Powderfinger" wrote:
.
"sept2006" <sept2006@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:8856CA90-1089-4038-A8A1-8E380D002B3E@xxxxxxxxxxxxxxxx
I am using a form to enter criteria values in a query. I would like tomake
it so that if I leave a field blank, it will not filter out those values.reports"
How do I do this? I referenced "using parameters with queries and
when designing my form, so hopefully that is something you can look at ifyou
need reference.
Here's how I do it, but there's probably a better way:
Dim strFilter As String
Dim stsLNAMEFilter As String
Dim strFNAMEFilter As String
Dim strCIDFilter As String
Dim strDateFilter As String
If Len(Trim(Me.LName)) > 0 Then strLastNameFilter = "[LNAME] Like '" &
Me.LName & "*'"
If Len(Trim(Me.FName)) > 0 Then strFirstNameFilter = "[FNAME] = '" &
Me.FName & "'"
If IsNumeric(Me.CID) Then strCIDFilter = "[CID] = '" & Me.CID
If IsDate(Me.StartDate) And IsDate(Me.EndDate) then strDateFilter = "[IDate]
Between #" & Format$(Me.StartDate, "mm/dd/yyyy") & "# AND #" &
Format$(Me.EndDate, "mm/dd/yyyy") & "#"
' now that I have all the filters I connect them with an AND:
If Len(Trim(strLastNameFilter)) > 0 Then strFilter = strLastNameFilter
If Len(Trim(strFirstNameFilter)) > 0 Then strFilter = strFilter & " " &
"AND" & " " & strFirstNameFilter
If Len(Trim(strCIDFilter )) > 0 Then strFilter = strFilter & " " & "AND" &
" " & strCIDFilter
If Len(Trim(strDateFilter )) > 0 Then strFilter = strFilter & " " & "AND" &
" " & strDateFilter
' now I have to get rid of the "AND" if it is the first three characters of
the filter
If Left(strFilter , 3) = "AND" Then
strFilter = Right(strFilter , Len(strFilter ) - 3)
End If
We have our filter with just what we want.
- Follow-Ups:
- Re: How do I set the default value so that it includes all values?
- From: Powderfinger
- Re: How do I set the default value so that it includes all values?
- References:
- Re: How do I set the default value so that it includes all values?
- From: Powderfinger
- Re: How do I set the default value so that it includes all values?
- Prev by Date: Re: Can VB code be declared on fly
- Next by Date: Report Value Help
- Previous by thread: Re: How do I set the default value so that it includes all values?
- Next by thread: Re: How do I set the default value so that it includes all values?
- Index(es):
Relevant Pages
|