Problem when printing a report

G

Guest

I do a name search for a specific record in a file using a form and query.
If I find the record I print a report using the name from the form and other
data from the file record. If the record is not found I want to print just
the data from the form. ID is the record id in the form & query and also in
the report.
My code is:
Private Sub Command61_Click()
If Forms!RecpInput.RecordsetClone.RecordCount = 0 Then
DoCmd.OpenReport "LabelsRecptInput", acViewPreview, "[ID]=null"
Else
DoCmd.OpenReport "LabelsRecptInput", acViewPreview, , "[ID]=" & Me![ID]
End If
End Sub
This works when a record is found but I get the report with a error when
no record is found.
 
D

Duane Hookom

Null can't equal anything (not even Null) since Null is kinda like unknown.
An unknown value can't equal another unknown value. You can try
DoCmd.OpenReport "LabelsRecptInput", acViewPreview, "[ID] Is Null"
or
DoCmd.OpenReport "LabelsRecptInput", acViewPreview, "IsNull([ID])"
 
G

Guest

Yes that did eliminate the error, but now I'm not getting the data from the
form printed. I think that the problem is that because query does not find a
hit the form data that is in the query will not print. What I think I need Is
a separate report that prints fields from a form and not the associated
query. Can I do this? When I try to design a report it wants only to
reference data in a file.
 
D

Duane Hookom

I dont' have any idea what is on the form or what you expect to print. Is
there a reason why you want to print values that are not stored in a table?

--
Duane Hookom
MS Access MVP
--

Bob B said:
Yes that did eliminate the error, but now I'm not getting the data from
the
form printed. I think that the problem is that because query does not find
a
hit the form data that is in the query will not print. What I think I need
Is
a separate report that prints fields from a form and not the associated
query. Can I do this? When I try to design a report it wants only to
reference data in a file.
Bob B said:
I do a name search for a specific record in a file using a form and
query.
If I find the record I print a report using the name from the form and
other
data from the file record. If the record is not found I want to print
just
the data from the form. ID is the record id in the form & query and also
in
the report.
My code is:
Private Sub Command61_Click()
If Forms!RecpInput.RecordsetClone.RecordCount = 0 Then
DoCmd.OpenReport "LabelsRecptInput", acViewPreview,
"[ID]=null"
Else
DoCmd.OpenReport "LabelsRecptInput", acViewPreview, , "[ID]=" &
Me![ID]
End If
End Sub
This works when a record is found but I get the report with a error
when
no record is found.
 
G

Guest

Yes there is a reason. This is for a Non Profit emergency help organization.
The cllient has called for a appointment. I want to print the person's
name,date,and time of apointment, but not enter it in to the table until the
person actually comes in. If the person was here previously there record is
record on file and then I want to print additional info, for the person doing
the interview.

Duane Hookom said:
I dont' have any idea what is on the form or what you expect to print. Is
there a reason why you want to print values that are not stored in a table?

--
Duane Hookom
MS Access MVP
--

Bob B said:
Yes that did eliminate the error, but now I'm not getting the data from
the
form printed. I think that the problem is that because query does not find
a
hit the form data that is in the query will not print. What I think I need
Is
a separate report that prints fields from a form and not the associated
query. Can I do this? When I try to design a report it wants only to
reference data in a file.
Bob B said:
I do a name search for a specific record in a file using a form and
query.
If I find the record I print a report using the name from the form and
other
data from the file record. If the record is not found I want to print
just
the data from the form. ID is the record id in the form & query and also
in
the report.
My code is:
Private Sub Command61_Click()
If Forms!RecpInput.RecordsetClone.RecordCount = 0 Then
DoCmd.OpenReport "LabelsRecptInput", acViewPreview,
"[ID]=null"
Else
DoCmd.OpenReport "LabelsRecptInput", acViewPreview, , "[ID]=" &
Me![ID]
End If
End Sub
This works when a record is found but I get the report with a error
when
no record is found.
 
D

Duane Hookom

You can bind controls on reports to something like:
Control Source: =Forms!frmYourForm!txtYourControl
You might want to try add a subreport for the "additional info".

--
Duane Hookom
MS Access MVP
--

Bob B said:
Yes there is a reason. This is for a Non Profit emergency help
organization.
The cllient has called for a appointment. I want to print the person's
name,date,and time of apointment, but not enter it in to the table until
the
person actually comes in. If the person was here previously there record
is
record on file and then I want to print additional info, for the person
doing
the interview.

Duane Hookom said:
I dont' have any idea what is on the form or what you expect to print. Is
there a reason why you want to print values that are not stored in a
table?

--
Duane Hookom
MS Access MVP
--

Bob B said:
Yes that did eliminate the error, but now I'm not getting the data from
the
form printed. I think that the problem is that because query does not
find
a
hit the form data that is in the query will not print. What I think I
need
Is
a separate report that prints fields from a form and not the
associated
query. Can I do this? When I try to design a report it wants only to
reference data in a file.
:

I do a name search for a specific record in a file using a form and
query.
If I find the record I print a report using the name from the form and
other
data from the file record. If the record is not found I want to print
just
the data from the form. ID is the record id in the form & query and
also
in
the report.
My code is:
Private Sub Command61_Click()
If Forms!RecpInput.RecordsetClone.RecordCount = 0 Then
DoCmd.OpenReport "LabelsRecptInput", acViewPreview,
"[ID]=null"
Else
DoCmd.OpenReport "LabelsRecptInput", acViewPreview, , "[ID]=" &
Me![ID]
End If
End Sub
This works when a record is found but I get the report with a error
when
no record is found.
 
G

Guest

Yes that does it. Thanks

Duane Hookom said:
You can bind controls on reports to something like:
Control Source: =Forms!frmYourForm!txtYourControl
You might want to try add a subreport for the "additional info".

--
Duane Hookom
MS Access MVP
--

Bob B said:
Yes there is a reason. This is for a Non Profit emergency help
organization.
The cllient has called for a appointment. I want to print the person's
name,date,and time of apointment, but not enter it in to the table until
the
person actually comes in. If the person was here previously there record
is
record on file and then I want to print additional info, for the person
doing
the interview.

Duane Hookom said:
I dont' have any idea what is on the form or what you expect to print. Is
there a reason why you want to print values that are not stored in a
table?

--
Duane Hookom
MS Access MVP
--

Yes that did eliminate the error, but now I'm not getting the data from
the
form printed. I think that the problem is that because query does not
find
a
hit the form data that is in the query will not print. What I think I
need
Is
a separate report that prints fields from a form and not the
associated
query. Can I do this? When I try to design a report it wants only to
reference data in a file.
:

I do a name search for a specific record in a file using a form and
query.
If I find the record I print a report using the name from the form and
other
data from the file record. If the record is not found I want to print
just
the data from the form. ID is the record id in the form & query and
also
in
the report.
My code is:
Private Sub Command61_Click()
If Forms!RecpInput.RecordsetClone.RecordCount = 0 Then
DoCmd.OpenReport "LabelsRecptInput", acViewPreview,
"[ID]=null"
Else
DoCmd.OpenReport "LabelsRecptInput", acViewPreview, , "[ID]=" &
Me![ID]
End If
End Sub
This works when a record is found but I get the report with a error
when
no record is found.
 

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