Print just on record from a report

G

Guest

I read the thread posed back in 3/05 regarding this, and I was able to use
the answers provided to print one record from a report, when only one form
was used.

I need something similar which could include a subform:
I have projects that occasionally need to have design change requests
created. Some projects have more than one request. I would like to create a
situation where when I create my design request, I can print the report for
that specific request on that specific job.

I have an command button to generate the report, at first I had an
expression to ask for the project number and then the design change number. I
would like to automate the process so that it will take the information I
just entered on my form and subform, and generate the report without asking
for the information.

I am trying to use the criteria in my query:
[forms]![formname]![PrimaryKey]

but that does not seem to work when I plug that in under my subform field.

What am I missing?

Or should I just try to filter in code?
 
G

Guest

Private Sub ButtonName_Click()
DoCmd.OpenReport "ReportName", acViewNormal, "",
"[PrimaryKey]=[Forms]![MainForm]![SubForm].[Form]![PrimaryKey]", acNormal
End Sub
 
G

Guest

When you say: "[primaryKey]..." should I put in the primary key for the main
form before the "=" ?

Wayne-I-M said:
Private Sub ButtonName_Click()
DoCmd.OpenReport "ReportName", acViewNormal, "",
"[PrimaryKey]=[Forms]![MainForm]![SubForm].[Form]![PrimaryKey]", acNormal
End Sub



--
Wayne
Manchester, England.



Jacinda A said:
I read the thread posed back in 3/05 regarding this, and I was able to use
the answers provided to print one record from a report, when only one form
was used.

I need something similar which could include a subform:
I have projects that occasionally need to have design change requests
created. Some projects have more than one request. I would like to create a
situation where when I create my design request, I can print the report for
that specific request on that specific job.

I have an command button to generate the report, at first I had an
expression to ask for the project number and then the design change number. I
would like to automate the process so that it will take the information I
just entered on my form and subform, and generate the report without asking
for the information.

I am trying to use the criteria in my query:
[forms]![formname]![PrimaryKey]

but that does not seem to work when I plug that in under my subform field.

What am I missing?

Or should I just try to filter in code?
 
G

Guest

Put the primary field control name in the space in the code I posted.
Make sure it also on the report somewhere (can be hifdden if nes)


"[Put It Here]=[Forms]![MainForm]![SubForm].[Form]![Put It Here]",


--
Wayne
Manchester, England.



Jacinda A said:
When you say: "[primaryKey]..." should I put in the primary key for the main
form before the "=" ?

Wayne-I-M said:
Private Sub ButtonName_Click()
DoCmd.OpenReport "ReportName", acViewNormal, "",
"[PrimaryKey]=[Forms]![MainForm]![SubForm].[Form]![PrimaryKey]", acNormal
End Sub



--
Wayne
Manchester, England.



Jacinda A said:
I read the thread posed back in 3/05 regarding this, and I was able to use
the answers provided to print one record from a report, when only one form
was used.

I need something similar which could include a subform:
I have projects that occasionally need to have design change requests
created. Some projects have more than one request. I would like to create a
situation where when I create my design request, I can print the report for
that specific request on that specific job.

I have an command button to generate the report, at first I had an
expression to ask for the project number and then the design change number. I
would like to automate the process so that it will take the information I
just entered on my form and subform, and generate the report without asking
for the information.

I am trying to use the criteria in my query:
[forms]![formname]![PrimaryKey]

but that does not seem to work when I plug that in under my subform field.

What am I missing?

Or should I just try to filter in code?
 
G

Guest

My report does has all of the information from the main form and all of the
information from the sub... I'm still having a problem... it's asking me to
enter the Parameter value....
This is my code:
Private Sub DCN_Form_Click()
On Error GoTo Err_DCN_Form_Click

Dim stDocName As String

stDocName = "rptDCN"
DoCmd.OpenReport stDocName, acPreview, "",
"[number]=[forms]![frmDCN]![subform].[tblDCNsubform]![number]", acNormal

Exit_DCN_Form_Click:
Exit Sub

Err_DCN_Form_Click:
MsgBox Err.Description
Resume Exit_DCN_Form_Click

End Sub

Wayne-I-M said:
Put the primary field control name in the space in the code I posted.
Make sure it also on the report somewhere (can be hifdden if nes)


"[Put It Here]=[Forms]![MainForm]![SubForm].[Form]![Put It Here]",


--
Wayne
Manchester, England.



Jacinda A said:
When you say: "[primaryKey]..." should I put in the primary key for the main
form before the "=" ?

Wayne-I-M said:
Private Sub ButtonName_Click()
DoCmd.OpenReport "ReportName", acViewNormal, "",
"[PrimaryKey]=[Forms]![MainForm]![SubForm].[Form]![PrimaryKey]", acNormal
End Sub



--
Wayne
Manchester, England.



:

I read the thread posed back in 3/05 regarding this, and I was able to use
the answers provided to print one record from a report, when only one form
was used.

I need something similar which could include a subform:
I have projects that occasionally need to have design change requests
created. Some projects have more than one request. I would like to create a
situation where when I create my design request, I can print the report for
that specific request on that specific job.

I have an command button to generate the report, at first I had an
expression to ask for the project number and then the design change number. I
would like to automate the process so that it will take the information I
just entered on my form and subform, and generate the report without asking
for the information.

I am trying to use the criteria in my query:
[forms]![formname]![PrimaryKey]

but that does not seem to work when I plug that in under my subform field.

What am I missing?

Or should I just try to filter in code?
 
G

Guest

Private Sub ReportButton_Click()
DoCmd.OpenReport "rptDCN", acViewPreivew, "",
"[txtNumber]=[Forms]![frmDCN]![tblDCNsubform].[Form]![txtNumber]", acNormal
End Sub

The above will preview the report called rptDCN
(change acViewPreivew to acViewNormal if you want to print it)
when you click a button called Reportbutton

I would rename the control you have called number to txtnumber (do the same
of the report also.



--
Wayne
Manchester, England.



Jacinda A said:
My report does has all of the information from the main form and all of the
information from the sub... I'm still having a problem... it's asking me to
enter the Parameter value....
This is my code:
Private Sub DCN_Form_Click()
On Error GoTo Err_DCN_Form_Click

Dim stDocName As String

stDocName = "rptDCN"
DoCmd.OpenReport stDocName, acPreview, "",
"[number]=[forms]![frmDCN]![subform].[tblDCNsubform]![number]", acNormal

Exit_DCN_Form_Click:
Exit Sub

Err_DCN_Form_Click:
MsgBox Err.Description
Resume Exit_DCN_Form_Click

End Sub

Wayne-I-M said:
Put the primary field control name in the space in the code I posted.
Make sure it also on the report somewhere (can be hifdden if nes)


"[Put It Here]=[Forms]![MainForm]![SubForm].[Form]![Put It Here]",


--
Wayne
Manchester, England.



Jacinda A said:
When you say: "[primaryKey]..." should I put in the primary key for the main
form before the "=" ?

:

Private Sub ButtonName_Click()
DoCmd.OpenReport "ReportName", acViewNormal, "",
"[PrimaryKey]=[Forms]![MainForm]![SubForm].[Form]![PrimaryKey]", acNormal
End Sub



--
Wayne
Manchester, England.



:

I read the thread posed back in 3/05 regarding this, and I was able to use
the answers provided to print one record from a report, when only one form
was used.

I need something similar which could include a subform:
I have projects that occasionally need to have design change requests
created. Some projects have more than one request. I would like to create a
situation where when I create my design request, I can print the report for
that specific request on that specific job.

I have an command button to generate the report, at first I had an
expression to ask for the project number and then the design change number. I
would like to automate the process so that it will take the information I
just entered on my form and subform, and generate the report without asking
for the information.

I am trying to use the criteria in my query:
[forms]![formname]![PrimaryKey]

but that does not seem to work when I plug that in under my subform field.

What am I missing?

Or should I just try to filter in code?
 
G

Guest

ooops - typo

acViewPreivew
should be
acViewPreview

--
Wayne
Manchester, England.



Wayne-I-M said:
Private Sub ReportButton_Click()
DoCmd.OpenReport "rptDCN", acViewPreivew, "",
"[txtNumber]=[Forms]![frmDCN]![tblDCNsubform].[Form]![txtNumber]", acNormal
End Sub

The above will preview the report called rptDCN
(change acViewPreivew to acViewNormal if you want to print it)
when you click a button called Reportbutton

I would rename the control you have called number to txtnumber (do the same
of the report also.



--
Wayne
Manchester, England.



Jacinda A said:
My report does has all of the information from the main form and all of the
information from the sub... I'm still having a problem... it's asking me to
enter the Parameter value....
This is my code:
Private Sub DCN_Form_Click()
On Error GoTo Err_DCN_Form_Click

Dim stDocName As String

stDocName = "rptDCN"
DoCmd.OpenReport stDocName, acPreview, "",
"[number]=[forms]![frmDCN]![subform].[tblDCNsubform]![number]", acNormal

Exit_DCN_Form_Click:
Exit Sub

Err_DCN_Form_Click:
MsgBox Err.Description
Resume Exit_DCN_Form_Click

End Sub

Wayne-I-M said:
Put the primary field control name in the space in the code I posted.
Make sure it also on the report somewhere (can be hifdden if nes)


"[Put It Here]=[Forms]![MainForm]![SubForm].[Form]![Put It Here]",


--
Wayne
Manchester, England.



:

When you say: "[primaryKey]..." should I put in the primary key for the main
form before the "=" ?

:

Private Sub ButtonName_Click()
DoCmd.OpenReport "ReportName", acViewNormal, "",
"[PrimaryKey]=[Forms]![MainForm]![SubForm].[Form]![PrimaryKey]", acNormal
End Sub



--
Wayne
Manchester, England.



:

I read the thread posed back in 3/05 regarding this, and I was able to use
the answers provided to print one record from a report, when only one form
was used.

I need something similar which could include a subform:
I have projects that occasionally need to have design change requests
created. Some projects have more than one request. I would like to create a
situation where when I create my design request, I can print the report for
that specific request on that specific job.

I have an command button to generate the report, at first I had an
expression to ask for the project number and then the design change number. I
would like to automate the process so that it will take the information I
just entered on my form and subform, and generate the report without asking
for the information.

I am trying to use the criteria in my query:
[forms]![formname]![PrimaryKey]

but that does not seem to work when I plug that in under my subform field.

What am I missing?

Or should I just try to filter in code?
 
G

Guest

sorry to be a pest, I'm still getting a message asking for the parameter for
the second part of my code...

it is asking me for the parameter for
[forms]![frmDCN]![subform].[tblDCNsubform]![project_number]

I have tried putting in the primary key for the main form, and the subform.
Project number is the linking field between the two...

I'm confused.

Wayne-I-M said:
ooops - typo

acViewPreivew
should be
acViewPreview

--
Wayne
Manchester, England.



Wayne-I-M said:
Private Sub ReportButton_Click()
DoCmd.OpenReport "rptDCN", acViewPreivew, "",
"[txtNumber]=[Forms]![frmDCN]![tblDCNsubform].[Form]![txtNumber]", acNormal
End Sub

The above will preview the report called rptDCN
(change acViewPreivew to acViewNormal if you want to print it)
when you click a button called Reportbutton

I would rename the control you have called number to txtnumber (do the same
of the report also.



--
Wayne
Manchester, England.



Jacinda A said:
My report does has all of the information from the main form and all of the
information from the sub... I'm still having a problem... it's asking me to
enter the Parameter value....
This is my code:
Private Sub DCN_Form_Click()
On Error GoTo Err_DCN_Form_Click

Dim stDocName As String

stDocName = "rptDCN"
DoCmd.OpenReport stDocName, acPreview, "",
"[number]=[forms]![frmDCN]![subform].[tblDCNsubform]![number]", acNormal

Exit_DCN_Form_Click:
Exit Sub

Err_DCN_Form_Click:
MsgBox Err.Description
Resume Exit_DCN_Form_Click

End Sub

:

Put the primary field control name in the space in the code I posted.
Make sure it also on the report somewhere (can be hifdden if nes)


"[Put It Here]=[Forms]![MainForm]![SubForm].[Form]![Put It Here]",


--
Wayne
Manchester, England.



:

When you say: "[primaryKey]..." should I put in the primary key for the main
form before the "=" ?

:

Private Sub ButtonName_Click()
DoCmd.OpenReport "ReportName", acViewNormal, "",
"[PrimaryKey]=[Forms]![MainForm]![SubForm].[Form]![PrimaryKey]", acNormal
End Sub



--
Wayne
Manchester, England.



:

I read the thread posed back in 3/05 regarding this, and I was able to use
the answers provided to print one record from a report, when only one form
was used.

I need something similar which could include a subform:
I have projects that occasionally need to have design change requests
created. Some projects have more than one request. I would like to create a
situation where when I create my design request, I can print the report for
that specific request on that specific job.

I have an command button to generate the report, at first I had an
expression to ask for the project number and then the design change number. I
would like to automate the process so that it will take the information I
just entered on my form and subform, and generate the report without asking
for the information.

I am trying to use the criteria in my query:
[forms]![formname]![PrimaryKey]

but that does not seem to work when I plug that in under my subform field.

What am I missing?

Or should I just try to filter in code?
 
P

Pieter Wijnen

Forms!frmDCN!tblDCNsubform!Form!project_number

Pieter

Jacinda A said:
sorry to be a pest, I'm still getting a message asking for the parameter
for
the second part of my code...

it is asking me for the parameter for
[forms]![frmDCN]![subform].[tblDCNsubform]![project_number]

I have tried putting in the primary key for the main form, and the
subform.
Project number is the linking field between the two...

I'm confused.

Wayne-I-M said:
ooops - typo

acViewPreivew
should be
acViewPreview

--
Wayne
Manchester, England.



Wayne-I-M said:
Private Sub ReportButton_Click()
DoCmd.OpenReport "rptDCN", acViewPreivew, "",
"[txtNumber]=[Forms]![frmDCN]![tblDCNsubform].[Form]![txtNumber]",
acNormal
End Sub

The above will preview the report called rptDCN
(change acViewPreivew to acViewNormal if you want to print it)
when you click a button called Reportbutton

I would rename the control you have called number to txtnumber (do the
same
of the report also.



--
Wayne
Manchester, England.



:

My report does has all of the information from the main form and all
of the
information from the sub... I'm still having a problem... it's asking
me to
enter the Parameter value....
This is my code:
Private Sub DCN_Form_Click()
On Error GoTo Err_DCN_Form_Click

Dim stDocName As String

stDocName = "rptDCN"
DoCmd.OpenReport stDocName, acPreview, "",
"[number]=[forms]![frmDCN]![subform].[tblDCNsubform]![number]",
acNormal

Exit_DCN_Form_Click:
Exit Sub

Err_DCN_Form_Click:
MsgBox Err.Description
Resume Exit_DCN_Form_Click

End Sub

:

Put the primary field control name in the space in the code I
posted.
Make sure it also on the report somewhere (can be hifdden if nes)


"[Put It Here]=[Forms]![MainForm]![SubForm].[Form]![Put It Here]",


--
Wayne
Manchester, England.



:

When you say: "[primaryKey]..." should I put in the primary key
for the main
form before the "=" ?

:

Private Sub ButtonName_Click()
DoCmd.OpenReport "ReportName", acViewNormal, "",
"[PrimaryKey]=[Forms]![MainForm]![SubForm].[Form]![PrimaryKey]",
acNormal
End Sub



--
Wayne
Manchester, England.



:

I read the thread posed back in 3/05 regarding this, and I
was able to use
the answers provided to print one record from a report, when
only one form
was used.

I need something similar which could include a subform:
I have projects that occasionally need to have design change
requests
created. Some projects have more than one request. I would
like to create a
situation where when I create my design request, I can print
the report for
that specific request on that specific job.

I have an command button to generate the report, at first I
had an
expression to ask for the project number and then the design
change number. I
would like to automate the process so that it will take the
information I
just entered on my form and subform, and generate the report
without asking
for the information.

I am trying to use the criteria in my query:
[forms]![formname]![PrimaryKey]

but that does not seem to work when I plug that in under my
subform field.

What am I missing?

Or should I just try to filter in code?
 
G

Guest

didn't work...

Pieter Wijnen said:
Forms!frmDCN!tblDCNsubform!Form!project_number

Pieter

Jacinda A said:
sorry to be a pest, I'm still getting a message asking for the parameter
for
the second part of my code...

it is asking me for the parameter for
[forms]![frmDCN]![subform].[tblDCNsubform]![project_number]

I have tried putting in the primary key for the main form, and the
subform.
Project number is the linking field between the two...

I'm confused.

Wayne-I-M said:
ooops - typo

acViewPreivew
should be
acViewPreview

--
Wayne
Manchester, England.



:

Private Sub ReportButton_Click()
DoCmd.OpenReport "rptDCN", acViewPreivew, "",
"[txtNumber]=[Forms]![frmDCN]![tblDCNsubform].[Form]![txtNumber]",
acNormal
End Sub

The above will preview the report called rptDCN
(change acViewPreivew to acViewNormal if you want to print it)
when you click a button called Reportbutton

I would rename the control you have called number to txtnumber (do the
same
of the report also.



--
Wayne
Manchester, England.



:

My report does has all of the information from the main form and all
of the
information from the sub... I'm still having a problem... it's asking
me to
enter the Parameter value....
This is my code:
Private Sub DCN_Form_Click()
On Error GoTo Err_DCN_Form_Click

Dim stDocName As String

stDocName = "rptDCN"
DoCmd.OpenReport stDocName, acPreview, "",
"[number]=[forms]![frmDCN]![subform].[tblDCNsubform]![number]",
acNormal

Exit_DCN_Form_Click:
Exit Sub

Err_DCN_Form_Click:
MsgBox Err.Description
Resume Exit_DCN_Form_Click

End Sub

:

Put the primary field control name in the space in the code I
posted.
Make sure it also on the report somewhere (can be hifdden if nes)


"[Put It Here]=[Forms]![MainForm]![SubForm].[Form]![Put It Here]",


--
Wayne
Manchester, England.



:

When you say: "[primaryKey]..." should I put in the primary key
for the main
form before the "=" ?

:

Private Sub ButtonName_Click()
DoCmd.OpenReport "ReportName", acViewNormal, "",
"[PrimaryKey]=[Forms]![MainForm]![SubForm].[Form]![PrimaryKey]",
acNormal
End Sub



--
Wayne
Manchester, England.



:

I read the thread posed back in 3/05 regarding this, and I
was able to use
the answers provided to print one record from a report, when
only one form
was used.

I need something similar which could include a subform:
I have projects that occasionally need to have design change
requests
created. Some projects have more than one request. I would
like to create a
situation where when I create my design request, I can print
the report for
that specific request on that specific job.

I have an command button to generate the report, at first I
had an
expression to ask for the project number and then the design
change number. I
would like to automate the process so that it will take the
information I
just entered on my form and subform, and generate the report
without asking
for the information.

I am trying to use the criteria in my query:
[forms]![formname]![PrimaryKey]

but that does not seem to work when I plug that in under my
subform field.

What am I missing?

Or should I just try to filter in code?
 
P

Pieter Wijnen

Sorry didn't read the whole story
If The Button is on the main form try:
DoCmd.OpenReport stDocName, acPreview, WhereCondition:="[Number]=" &
Me.frmDCN.Form.Project_Number.Value
You should not put the Criteria both in the startup code & Query, choose
either

Pieter

PS Check that the *Control* for The Subform really is named frmDCN.
I Assume that that's the name of the *Form*, but the Control may have a
different name


Jacinda A said:
didn't work...

Pieter Wijnen said:
Forms!frmDCN!tblDCNsubform!Form!project_number

Pieter

Jacinda A said:
sorry to be a pest, I'm still getting a message asking for the
parameter
for
the second part of my code...

it is asking me for the parameter for
[forms]![frmDCN]![subform].[tblDCNsubform]![project_number]

I have tried putting in the primary key for the main form, and the
subform.
Project number is the linking field between the two...

I'm confused.

:

ooops - typo

acViewPreivew
should be
acViewPreview

--
Wayne
Manchester, England.



:

Private Sub ReportButton_Click()
DoCmd.OpenReport "rptDCN", acViewPreivew, "",
"[txtNumber]=[Forms]![frmDCN]![tblDCNsubform].[Form]![txtNumber]",
acNormal
End Sub

The above will preview the report called rptDCN
(change acViewPreivew to acViewNormal if you want to print it)
when you click a button called Reportbutton

I would rename the control you have called number to txtnumber (do
the
same
of the report also.



--
Wayne
Manchester, England.



:

My report does has all of the information from the main form and
all
of the
information from the sub... I'm still having a problem... it's
asking
me to
enter the Parameter value....
This is my code:
Private Sub DCN_Form_Click()
On Error GoTo Err_DCN_Form_Click

Dim stDocName As String

stDocName = "rptDCN"
DoCmd.OpenReport stDocName, acPreview, "",
"[number]=[forms]![frmDCN]![subform].[tblDCNsubform]![number]",
acNormal

Exit_DCN_Form_Click:
Exit Sub

Err_DCN_Form_Click:
MsgBox Err.Description
Resume Exit_DCN_Form_Click

End Sub

:

Put the primary field control name in the space in the code I
posted.
Make sure it also on the report somewhere (can be hifdden if
nes)


"[Put It Here]=[Forms]![MainForm]![SubForm].[Form]![Put It
Here]",


--
Wayne
Manchester, England.



:

When you say: "[primaryKey]..." should I put in the primary
key
for the main
form before the "=" ?

:

Private Sub ButtonName_Click()
DoCmd.OpenReport "ReportName", acViewNormal, "",
"[PrimaryKey]=[Forms]![MainForm]![SubForm].[Form]![PrimaryKey]",
acNormal
End Sub



--
Wayne
Manchester, England.



:

I read the thread posed back in 3/05 regarding this, and I
was able to use
the answers provided to print one record from a report,
when
only one form
was used.

I need something similar which could include a subform:
I have projects that occasionally need to have design
change
requests
created. Some projects have more than one request. I would
like to create a
situation where when I create my design request, I can
print
the report for
that specific request on that specific job.

I have an command button to generate the report, at first
I
had an
expression to ask for the project number and then the
design
change number. I
would like to automate the process so that it will take
the
information I
just entered on my form and subform, and generate the
report
without asking
for the information.

I am trying to use the criteria in my query:
[forms]![formname]![PrimaryKey]

but that does not seem to work when I plug that in under
my
subform field.

What am I missing?

Or should I just try to filter in code?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top