Okay, I have never done a report like that but I just did one to see what
happens. And I see it takes on the same Record Source as the form, so
what
is the Record Source of the form? I also noticed that my calculated
fields
(the ones located directly on the form show #Error). I also noticed that
is
shows every record, so I fixed my button to just show me whatever record
I
was previewing.
After doing all that, the source of your report is not the form but the
Record Source of the form, so once again, what is the Record Source of
the
report? I know you can see the information on the form but something
must
have changed which is why I want you to look at the Record Source of the
report.
I am not sure why it doesn't work either but might as well start with
obvious and move on from there.
Gina Whipp
Kirt84 said:
The source of the Report is the Form. I done a Save As on the Form and
saved
it in Report format. The fields on the Report are sourced from the
Form -
not
sure why it doesn't work?
--
Thank you for your help
:
What is the source of the report? A query??? Take a look at the
query,
can
you find the ECMA record in the query?
Thank you - this is now only previewing the one Record, however no
information is populated in the text boxes on the Report.
ECMA is the name of the field on the table and txtECMA is the name
of
the
text box. The code I have put in is below:
Private Sub Command300_Click()
On Error GoTo Err_Command300_Click
Dim stDocName As String
Dim strWhere As String
strWhere = "[ECMA]=" & Me![EMCA]
stDocName = "ProductDetails1"
DoCmd.OpenReport "ProductDetails1", acViewPreview, , "[ECMA]=' " &
Me![txtEMCA] & " ' "
Exit_Command300_Click:
Exit Sub
Err_Command300_Click:
MsgBox Err.Description
Resume Exit_Command300_Click
End Sub
--
Thank you for your help
:
Kirt84,
I would use the below line...
Private Sub Command300_Click()
DoCmd.OpenReport "ProductDetails1", acViewPreview, , "[ECMA]='
"
&
Me![EMCA] & " ' "
End Sub
However, if you want to just fix the strWhere line then below
should
do
it.
Also, you may need another comma after acPreview (so there would be
2
commas). I also noticed ECMA and then Me![txtEMCA], are they
suppose
to
be
the same? If there are suppose to be different ignore that.
If a text field: strWhere = "[ECMA]=' " & Me![EMCA] & " ' "
If a numeric field: strWhere = "[ECMA]=" & Me![txtEMCA]
HTH,
Gina Whipp
I have a Form and only want to print the Record that is displayed.
On
the
Form I have a command button that opens up a report that is
supposed
to
show
the current record. However, currently it is previewing all the
records
in
the database - the code for this is shown below . (The ECMA is
the
unique
field)
Private Sub Command300_Click()
On Error GoTo Err_Command300_Click
Dim stDocName As String
Dim strWhere As String
strWhere = "[ECMA] = """ & Me.txtEMCA & """"
stDocName = "ProductDetails1"
DoCmd.OpenReport stDocName, acPreview, strWhere
Exit_Command300_Click:
Exit Sub
Err_Command300_Click:
MsgBox Err.Description
Resume Exit_Command300_Click
End Sub