473,395 Members | 1,386 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

where_condition in Sub-Reports !!

I have a main Report with 3 sub-reports eg:

Report1 (Main Report) ... SubRpt1, SubRpt2, SubRpt3
SubRpt1, SubRpt2 & SubRpt3 are bound to 3 different tables with a
common relation on a NUMERIC field called Service_Ticket_No
(Ser_Tkt_Num).

The Main Report is not bound to any table but I could if required.
I have a similar FORM setup - Main Form + 3 Subforms. This form has a
PRINT button. When the user clicks that print button I would like to
print only the Service ticket he is positioned on. This is my code:

==== Code Snippet ========
Private Sub Cmd_Print_Click()
On Error GoTo Err_Cmd_Print_Click

Dim stDocName As String
Dim where_condition As String

stDocName = "Report1"
where_condition = "Ser_Tkt_Num = " & Me.Ser_Tkt_Num

With DoCmd
.OpenReport stDocName, acPreview, , where_condition
.Maximize
.RunCommand acCmdFitToWindow
End With
Exit_Cmd_Print_Click:
Exit Sub

Err_Cmd_Print_Click:
MsgBox Err.Description
Resume Exit_Cmd_Print_Click

End Sub
==== End of Code Snippet ============

My Problem:
~~~~~~~~~~
All the service tickets print.
I presume the parameter (Ser_Tkt_Num) is not visible to the
subreports. How can I accomplish this ?
Thks & Best Rgds,
Prakash.
Nov 12 '05 #1
5 3317
The WhereCondition is applied to the main report.
Since that is unbound, it hs no effect.

The simplest way to do this would be to add a text box to the main report,
and set its Control Source to:
[Forms]![YourForm]![Ser_Tkt_Num]

Then in the LinkMasterFields of your subreports, enter the name of the text
box. In the LinkChildFields, enter the name of the matching field (the
foreign key) in each subreport.

Another way to achieve the same result would be to include
=[Forms]![YourForm]![Ser_Tkt_Num]
in the Critieria of the queries (under the foreign key field).

A third alternative would be to use the Report_Open event of the subreports
to set their Filter property so they only show the desired records.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"Prakash Wadhwani" <si****@omantel.net.om> wrote in message
news:60**************************@posting.google.c om...
I have a main Report with 3 sub-reports eg:

Report1 (Main Report) ... SubRpt1, SubRpt2, SubRpt3
SubRpt1, SubRpt2 & SubRpt3 are bound to 3 different tables with a
common relation on a NUMERIC field called Service_Ticket_No
(Ser_Tkt_Num).

The Main Report is not bound to any table but I could if required.
I have a similar FORM setup - Main Form + 3 Subforms. This form has a
PRINT button. When the user clicks that print button I would like to
print only the Service ticket he is positioned on. This is my code:

==== Code Snippet ========
Private Sub Cmd_Print_Click()
On Error GoTo Err_Cmd_Print_Click

Dim stDocName As String
Dim where_condition As String

stDocName = "Report1"
where_condition = "Ser_Tkt_Num = " & Me.Ser_Tkt_Num

With DoCmd
.OpenReport stDocName, acPreview, , where_condition
.Maximize
.RunCommand acCmdFitToWindow
End With
Exit_Cmd_Print_Click:
Exit Sub

Err_Cmd_Print_Click:
MsgBox Err.Description
Resume Exit_Cmd_Print_Click

End Sub
==== End of Code Snippet ============

My Problem:
~~~~~~~~~~
All the service tickets print.
I presume the parameter (Ser_Tkt_Num) is not visible to the
subreports. How can I accomplish this ?
Thks & Best Rgds,
Prakash.

Nov 12 '05 #2
Allen ... Wow !! 3 God-Send (sorry Allen-Send) alternatives. Thx! I'm
gonna try one of them tomorrow morning 1st thing.

Once again .. thx a ton !! I'll sure get back to you after I've tried
it. But any which way's ... one of them solutions has gotta work ...
Whew !!

Muchos Gracias !
Best Rgds,
Prakash.


"Allen Browne" <ab***************@bigpond.net.au> wrote in message news:<NA********************@news-server.bigpond.net.au>...
The WhereCondition is applied to the main report.
Since that is unbound, it hs no effect.

The simplest way to do this would be to add a text box to the main report,
and set its Control Source to:
[Forms]![YourForm]![Ser_Tkt_Num]

Then in the LinkMasterFields of your subreports, enter the name of the text
box. In the LinkChildFields, enter the name of the matching field (the
foreign key) in each subreport.

Another way to achieve the same result would be to include
=[Forms]![YourForm]![Ser_Tkt_Num]
in the Critieria of the queries (under the foreign key field).

A third alternative would be to use the Report_Open event of the subreports
to set their Filter property so they only show the desired records.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"Prakash Wadhwani" <si****@omantel.net.om> wrote in message
news:60**************************@posting.google.c om...
I have a main Report with 3 sub-reports eg:

Report1 (Main Report) ... SubRpt1, SubRpt2, SubRpt3
SubRpt1, SubRpt2 & SubRpt3 are bound to 3 different tables with a
common relation on a NUMERIC field called Service_Ticket_No
(Ser_Tkt_Num).

The Main Report is not bound to any table but I could if required.
I have a similar FORM setup - Main Form + 3 Subforms. This form has a
PRINT button. When the user clicks that print button I would like to
print only the Service ticket he is positioned on. This is my code:

==== Code Snippet ========
Private Sub Cmd_Print_Click()
On Error GoTo Err_Cmd_Print_Click

Dim stDocName As String
Dim where_condition As String

stDocName = "Report1"
where_condition = "Ser_Tkt_Num = " & Me.Ser_Tkt_Num

With DoCmd
.OpenReport stDocName, acPreview, , where_condition
.Maximize
.RunCommand acCmdFitToWindow
End With
Exit_Cmd_Print_Click:
Exit Sub

Err_Cmd_Print_Click:
MsgBox Err.Description
Resume Exit_Cmd_Print_Click

End Sub
==== End of Code Snippet ============

My Problem:
~~~~~~~~~~
All the service tickets print.
I presume the parameter (Ser_Tkt_Num) is not visible to the
subreports. How can I accomplish this ?
Thks & Best Rgds,
Prakash.

Nov 12 '05 #3
Allen ... I opted for the 3rd option viz setting a filter in the Open
Report Event. However I get the following eror msg:

Run Time Eror 2101
The Setting you sntered isn't valid for this property.

Here is my code in the Open Report Event:

Private Sub Report_Open(Cancel As Integer)
'Me.Filter = Forms.Service_Ticket_Master.Ser_Tkt_Num
Me.Filter = "Me.Ser_Tkt_Num = " &
Forms!Service_Ticket_Master!Ser_Tkt_Num
Me.FilterOn = True
End Sub

I tried both the above filter options incl the option rem'med out.
Both give the same eror. Can you please tell me where I'm going wrong
??

BTW, I did finally try your first option & it worked but I'd really
prefer to use the 3rd option.

Thx & Best Rgds,
Prakash.

"Allen Browne" <ab***************@bigpond.net.au> wrote in message news:<NA********************@news-server.bigpond.net.au>...
The WhereCondition is applied to the main report.
Since that is unbound, it hs no effect.

The simplest way to do this would be to add a text box to the main report,
and set its Control Source to:
[Forms]![YourForm]![Ser_Tkt_Num]

Then in the LinkMasterFields of your subreports, enter the name of the text
box. In the LinkChildFields, enter the name of the matching field (the
foreign key) in each subreport.

Another way to achieve the same result would be to include
=[Forms]![YourForm]![Ser_Tkt_Num]
in the Critieria of the queries (under the foreign key field).

A third alternative would be to use the Report_Open event of the subreports
to set their Filter property so they only show the desired records.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"Prakash Wadhwani" <si****@omantel.net.om> wrote in message
news:60**************************@posting.google.c om...
I have a main Report with 3 sub-reports eg:

Report1 (Main Report) ... SubRpt1, SubRpt2, SubRpt3
SubRpt1, SubRpt2 & SubRpt3 are bound to 3 different tables with a
common relation on a NUMERIC field called Service_Ticket_No
(Ser_Tkt_Num).

The Main Report is not bound to any table but I could if required.
I have a similar FORM setup - Main Form + 3 Subforms. This form has a
PRINT button. When the user clicks that print button I would like to
print only the Service ticket he is positioned on. This is my code:

==== Code Snippet ========
Private Sub Cmd_Print_Click()
On Error GoTo Err_Cmd_Print_Click

Dim stDocName As String
Dim where_condition As String

stDocName = "Report1"
where_condition = "Ser_Tkt_Num = " & Me.Ser_Tkt_Num

With DoCmd
.OpenReport stDocName, acPreview, , where_condition
.Maximize
.RunCommand acCmdFitToWindow
End With
Exit_Cmd_Print_Click:
Exit Sub

Err_Cmd_Print_Click:
MsgBox Err.Description
Resume Exit_Cmd_Print_Click

End Sub
==== End of Code Snippet ============

My Problem:
~~~~~~~~~~
All the service tickets print.
I presume the parameter (Ser_Tkt_Num) is not visible to the
subreports. How can I accomplish this ?
Thks & Best Rgds,
Prakash.

Nov 12 '05 #4
What is the data type of the field Ser_Tkt_Num?

If it's Text, you need extra quotes:
Me.Filter = "Me.Ser_Tkt_Num = """ & _
Forms!Service_Ticket_Master!Ser_Tkt_Num & """"

That should be fine for a main report. Not sure about a subreport.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Prakash Wadhwani" <si****@omantel.net.om> wrote in message
news:60*************************@posting.google.co m...
Allen ... I opted for the 3rd option viz setting a filter in the Open
Report Event. However I get the following eror msg:

Run Time Eror 2101
The Setting you sntered isn't valid for this property.

Here is my code in the Open Report Event:

Private Sub Report_Open(Cancel As Integer)
'Me.Filter = Forms.Service_Ticket_Master.Ser_Tkt_Num
Me.Filter = "Me.Ser_Tkt_Num = " &
Forms!Service_Ticket_Master!Ser_Tkt_Num
Me.FilterOn = True
End Sub

I tried both the above filter options incl the option rem'med out.
Both give the same eror. Can you please tell me where I'm going wrong
??

BTW, I did finally try your first option & it worked but I'd really
prefer to use the 3rd option.

Thx & Best Rgds,
Prakash.

"Allen Browne" <ab***************@bigpond.net.au> wrote in message

news:<NA********************@news-server.bigpond.net.au>...
The WhereCondition is applied to the main report.
Since that is unbound, it hs no effect.

The simplest way to do this would be to add a text box to the main report, and set its Control Source to:
[Forms]![YourForm]![Ser_Tkt_Num]

Then in the LinkMasterFields of your subreports, enter the name of the text box. In the LinkChildFields, enter the name of the matching field (the
foreign key) in each subreport.

Another way to achieve the same result would be to include
=[Forms]![YourForm]![Ser_Tkt_Num]
in the Critieria of the queries (under the foreign key field).

A third alternative would be to use the Report_Open event of the subreports to set their Filter property so they only show the desired records.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"Prakash Wadhwani" <si****@omantel.net.om> wrote in message
news:60**************************@posting.google.c om...
I have a main Report with 3 sub-reports eg:

Report1 (Main Report) ... SubRpt1, SubRpt2, SubRpt3
SubRpt1, SubRpt2 & SubRpt3 are bound to 3 different tables with a
common relation on a NUMERIC field called Service_Ticket_No
(Ser_Tkt_Num).

The Main Report is not bound to any table but I could if required.
I have a similar FORM setup - Main Form + 3 Subforms. This form has a
PRINT button. When the user clicks that print button I would like to
print only the Service ticket he is positioned on. This is my code:

==== Code Snippet ========
Private Sub Cmd_Print_Click()
On Error GoTo Err_Cmd_Print_Click

Dim stDocName As String
Dim where_condition As String

stDocName = "Report1"
where_condition = "Ser_Tkt_Num = " & Me.Ser_Tkt_Num

With DoCmd
.OpenReport stDocName, acPreview, , where_condition
.Maximize
.RunCommand acCmdFitToWindow
End With
Exit_Cmd_Print_Click:
Exit Sub

Err_Cmd_Print_Click:
MsgBox Err.Description
Resume Exit_Cmd_Print_Click

End Sub
==== End of Code Snippet ============

My Problem:
~~~~~~~~~~
All the service tickets print.
I presume the parameter (Ser_Tkt_Num) is not visible to the
subreports. How can I accomplish this ?
Thks & Best Rgds,
Prakash.

Nov 12 '05 #5
Allen the field type is numeric. I've even put a msgbox there & it
shows the right value but I still get that Run Time error msg. I guess
it has something to do with sub-reports.

Thx & Best Rgds,
Prakash


"Allen Browne" <al*********@SeeSig.invalid> wrote in message news:<1d********************@news-server.bigpond.net.au>...
What is the data type of the field Ser_Tkt_Num?

If it's Text, you need extra quotes:
Me.Filter = "Me.Ser_Tkt_Num = """ & _
Forms!Service_Ticket_Master!Ser_Tkt_Num & """"

That should be fine for a main report. Not sure about a subreport.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Prakash Wadhwani" <si****@omantel.net.om> wrote in message
news:60*************************@posting.google.co m...
Allen ... I opted for the 3rd option viz setting a filter in the Open
Report Event. However I get the following eror msg:

Run Time Eror 2101
The Setting you sntered isn't valid for this property.

Here is my code in the Open Report Event:

Private Sub Report_Open(Cancel As Integer)
'Me.Filter = Forms.Service_Ticket_Master.Ser_Tkt_Num
Me.Filter = "Me.Ser_Tkt_Num = " &
Forms!Service_Ticket_Master!Ser_Tkt_Num
Me.FilterOn = True
End Sub

I tried both the above filter options incl the option rem'med out.
Both give the same eror. Can you please tell me where I'm going wrong
??

BTW, I did finally try your first option & it worked but I'd really
prefer to use the 3rd option.

Thx & Best Rgds,
Prakash.

"Allen Browne" <ab***************@bigpond.net.au> wrote in message

news:<NA********************@news-server.bigpond.net.au>...
The WhereCondition is applied to the main report.
Since that is unbound, it hs no effect.

The simplest way to do this would be to add a text box to the main report, and set its Control Source to:
[Forms]![YourForm]![Ser_Tkt_Num]

Then in the LinkMasterFields of your subreports, enter the name of the text box. In the LinkChildFields, enter the name of the matching field (the
foreign key) in each subreport.

Another way to achieve the same result would be to include
=[Forms]![YourForm]![Ser_Tkt_Num]
in the Critieria of the queries (under the foreign key field).

A third alternative would be to use the Report_Open event of the subreports to set their Filter property so they only show the desired records.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"Prakash Wadhwani" <si****@omantel.net.om> wrote in message
news:60**************************@posting.google.c om...
> I have a main Report with 3 sub-reports eg:
>
> Report1 (Main Report) ... SubRpt1, SubRpt2, SubRpt3
>
>
> SubRpt1, SubRpt2 & SubRpt3 are bound to 3 different tables with a
> common relation on a NUMERIC field called Service_Ticket_No
> (Ser_Tkt_Num).
>
> The Main Report is not bound to any table but I could if required.
>
>
> I have a similar FORM setup - Main Form + 3 Subforms. This form has a
> PRINT button. When the user clicks that print button I would like to
> print only the Service ticket he is positioned on. This is my code:
>
> ==== Code Snippet ========
> Private Sub Cmd_Print_Click()
> On Error GoTo Err_Cmd_Print_Click
>
> Dim stDocName As String
> Dim where_condition As String
>
> stDocName = "Report1"
> where_condition = "Ser_Tkt_Num = " & Me.Ser_Tkt_Num
>
> With DoCmd
> .OpenReport stDocName, acPreview, , where_condition
> .Maximize
> .RunCommand acCmdFitToWindow
> End With
>
>
> Exit_Cmd_Print_Click:
> Exit Sub
>
> Err_Cmd_Print_Click:
> MsgBox Err.Description
> Resume Exit_Cmd_Print_Click
>
> End Sub
> ==== End of Code Snippet ============
>
>
>
> My Problem:
> ~~~~~~~~~~
> All the service tickets print.
> I presume the parameter (Ser_Tkt_Num) is not visible to the
> subreports. How can I accomplish this ?
>
>
> Thks & Best Rgds,
> Prakash.

Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: John Dewbert | last post by:
*** post for FREE via your newsreader at post.newsfeed.com *** Hello, I have trouble passing a folder object (from a FileSystemObject) to a sub procedure. Consider the following code: ...
2
by: tshad | last post by:
I have an example I copied from "programming asp.net" (o'reilly) and can't seem to get the Sub (writefile) to execute. It displays all the response.write lines that are called directly, but not...
5
by: Colleyville Alan | last post by:
I have a sub that can do two different tasks based on the value of one variable. So I'd like to have two different buttons on the same form run this, but each one setting a flag so that the...
3
by: Kathy Burke | last post by:
Hi, I'm tired, so this question may be silly. I have a fairly long sub procedure. Based on one condition, I load another sub with the following: If Session("GRN") = "complete" Then txtScan.Text...
10
by: tmaster | last post by:
When I try to dynamically add a second sub menu item to this ContextMenu item, I get an error 'Specified argument was out of the range of valid values'. Private Sub mnuTopics_Show_Select(ByVal...
12
by: Ron | last post by:
Greetings, I am trying to understand the rational for Raising Events instead of just calling a sub. Could someone explain the difference between the following 2 scenarios? Why would I want to...
5
by: Sharon | last post by:
Hi all. To prevent access to a sub system internal types, is it necessary to create the sub system in a different project, and use the internal access level? Or is there another way that will...
6
by: Bob | last post by:
Hi, I found this code here below (about cartitems and shoppingcart) and I have two questions about sub New(). In the first class CartItem, there is two times sub New(): Public Sub New() End...
6
by: Greg Strong | last post by:
Hello All, Is is possible to use an ADO recordset to populate an unbound continuous Subform? I've done some Googling without much luck, so this maybe impossible, but let me try to explain...
6
by: Thom Little | last post by:
Using C# 3.5 I have a form that calls many other sub-forms. Typically there will be five forms open at the same time. If the main form is closed all the sub forms are also closed. Is there...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.