Printing report from subform control (1 Viewer)

megamef

Registered User.
Local time
Today, 16:48
Joined
Apr 18, 2013
Messages
161
Hi All,

I'm using access 2003

I've successfully printed a report from a main form control and now I'm trying to do the same with a subform control.

I'm using a query to filter the report, with the criteria of:

Code:
[forms]![MainForm]![Subform].[form]![textbox]

Is there something I'm missing?

Cheers

Steve
 

megamef

Registered User.
Local time
Today, 16:48
Joined
Apr 18, 2013
Messages
161
This is probably against the forum rules, but I'm bumping this, as i posted 8 hours ago without a reply.
 

pr2-eugin

Super Moderator
Local time
Today, 16:48
Joined
Nov 30, 2011
Messages
8,494
*HINT* Maybe let us know what the problem is *HINT*

The reason no one has replied maybe because they were not sure what your problem was.. As you have said, what you are doing, but nowhere in your post say what is the problem/where you are stuck at.. So people are puzzled what to reply..
 

megamef

Registered User.
Local time
Today, 16:48
Joined
Apr 18, 2013
Messages
161
Ah ok,

My problem is that when i press the button to print the report, a messagebox appears that i have to enter the value into manually, but i do not need to do this on the main form.
 

pr2-eugin

Super Moderator
Local time
Today, 16:48
Joined
Nov 30, 2011
Messages
8,494
Is it possible for us to see the code in the button click? Is the form still open at the stage of printing?
 

megamef

Registered User.
Local time
Today, 16:48
Joined
Apr 18, 2013
Messages
161
Sorry for late reply, here is button code:

Code:
Private Sub PrintJobReport_Click()
' This code created by Command Button Wizard.
On Error GoTo Err_PrintJobReport_Click

    Dim strDocName2 As String
    
    strDocName2 = "job report"
    ' Print Invoice report, using Invoices Filter query to print
    ' invoice for current order.
    DoCmd.OpenReport strDocName2, acViewNormal, "job report filter"
Exit_PrintJobReport_Click:
    Exit Sub

Err_PrintJobReport_Click:
    ' If action was cancelled by the user, don't display an error message.
    Const conErrDoCmdCancelled = 2501
    If (Err = conErrDoCmdCancelled) Then
        Resume Exit_PrintJobReport_Click
    Else
        MsgBox Err.Description
        Resume Exit_PrintJobReport_Click
    End If

End Sub

job report filter contains the code I posted first as it's criteria.
 

pr2-eugin

Super Moderator
Local time
Today, 16:48
Joined
Nov 30, 2011
Messages
8,494
Well that is the main bit that I would wanted to see, as that is the one which is not working.. The Filter setting might be wrong.. It should be something like..
Code:
the_Field_On_The_Report_You_Wish_To_Set_The_Filer = [Forms]![MainForm]![Subform].[Form]![TextBox]
 

megamef

Registered User.
Local time
Today, 16:48
Joined
Apr 18, 2013
Messages
161
Yes. I have done that. Thank you for your help, i was just wondering if i had missed something more basic. Thank you.
 

megamef

Registered User.
Local time
Today, 16:48
Joined
Apr 18, 2013
Messages
161
No it isn't, i still need to manually enter the value rather than the button passing the value from the control on the subform. Based on what i've read on the internet (and i've been battling this on and off for a few days now) i'm using the correct syntax.

What is more fustrating is that if i copy the button and button code into the subform itself and run the subform as a stand alone form it does work, but doesn't when i run it as an embeded form from the main form.
 

Users who are viewing this thread

Top Bottom