Group:  Microsoft Access ยป microsoft.public.access.gettingstarted
Thread: Report filter

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Report filter
"eddy via AccessMonster.com" <u15846[ at ]uwe> 03.08.2006 03:29:13
Hi,

I have a form called "OM_ASP_Scan" . User will search by "Tag No", numbers
that created by autonumber and input some information to update. I also have
created two combo box to specify print range between "Tag No" and a command
button to preview a report. In the On Click event I've entered the following
code:

Private Sub Command48_Click()

On Error GoTo Err_Command62_Click

Dim stDocName As String


stDocName = "ASP_Detail" 'report name

DoCmd.OpenReport stDocName, acViewPreview, , "[Tag No] between " & Me!
[Combo44] & " and " & Me![Combo46]

Exit_Command62_Click:
Exit Sub

Err_Command62_Click:
MsgBox Err.Description
Resume Exit_Command62_Click
End Sub

It's working prefectly except when I tried to add more combo box to filter
by user input date that called "Date Send" field. I want the report shows
the chosen date only. It was quite confusing to customize the code, due to
that I really appreciate if anybody could give me some hand.


Thank you.


Regards

eddy

--
poyo's

Message posted via http://www.accessmonster.com

Re: Report filter
"Duane Hookom" <DuaneAtNoSpanHookomDotNet> 03.08.2006 03:39:52
I would rename the tagno combo boxes and use code like:
Private Sub Command48_Click()

On Error GoTo Err_Command62_Click

Dim stDocName As String
Dim strWhere as String

stDocName = "ASP_Detail" 'report name
strWhere = "1=1 "
If Not IsNull(Me.cboFrom) Then
strWhere = strWhere & " And [Tag No] >=" & Me.cboFrom
End If
If Not IsNull(Me.cboTo) Then
strWhere = strWhere & " And [Tag No] <=" & Me.cboTo
End If
If Not IsNull(Me.cboDate) Then
strWhere = strWhere & " And [Date Send] =#" & Me.cboDate & "#"
End If
DoCmd.OpenReport stDocName, acViewPreview, , strWhere

Exit_Command62_Click:
Exit Sub

Err_Command62_Click:
MsgBox Err.Description
Resume Exit_Command62_Click
End Sub

--
Duane Hookom
MS Access MVP

"eddy via AccessMonster.com" <u15846[ at ]uwe> wrote in message
news:6432730c28575[ at ]uwe...
[Quoted Text]
> Hi,
>
> I have a form called "OM_ASP_Scan" . User will search by "Tag No", numbers
> that created by autonumber and input some information to update. I also
> have
> created two combo box to specify print range between "Tag No" and a
> command
> button to preview a report. In the On Click event I've entered the
> following
> code:
>
> Private Sub Command48_Click()
>
> On Error GoTo Err_Command62_Click
>
> Dim stDocName As String
>
>
> stDocName = "ASP_Detail" 'report name
>
> DoCmd.OpenReport stDocName, acViewPreview, , "[Tag No] between " & Me!
> [Combo44] & " and " & Me![Combo46]
>
> Exit_Command62_Click:
> Exit Sub
>
> Err_Command62_Click:
> MsgBox Err.Description
> Resume Exit_Command62_Click
> End Sub
>
> It's working prefectly except when I tried to add more combo box to
> filter
> by user input date that called "Date Send" field. I want the report
> shows
> the chosen date only. It was quite confusing to customize the code, due to
> that I really appreciate if anybody could give me some hand.
>
>
> Thank you.
>
>
> Regards
>
> eddy
>
> --
> poyo's
>
> Message posted via http://www.accessmonster.com
>


Re: Report filter
"eddy via AccessMonster.com" <u15846[ at ]uwe> 03.08.2006 09:48:20
Thanks for your fast reply and it works perfectly!!

Thanks again, god bless you

Regards

Eddy



Duane Hookom wrote:
[Quoted Text]
>I would rename the tagno combo boxes and use code like:
>Private Sub Command48_Click()
>
>On Error GoTo Err_Command62_Click
>
> Dim stDocName As String
> Dim strWhere as String
>
> stDocName = "ASP_Detail" 'report name
> strWhere = "1=1 "
> If Not IsNull(Me.cboFrom) Then
> strWhere = strWhere & " And [Tag No] >=" & Me.cboFrom
> End If
> If Not IsNull(Me.cboTo) Then
> strWhere = strWhere & " And [Tag No] <=" & Me.cboTo
> End If
> If Not IsNull(Me.cboDate) Then
> strWhere = strWhere & " And [Date Send] =#" & Me.cboDate & "#"
> End If
> DoCmd.OpenReport stDocName, acViewPreview, , strWhere
>
>Exit_Command62_Click:
> Exit Sub
>
>Err_Command62_Click:
> MsgBox Err.Description
> Resume Exit_Command62_Click
>End Sub
>
>> Hi,
>>
>[quoted text clipped - 38 lines]
>>
>> eddy

--
poyo's

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-gettingstarted/200608/1

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net