If Statement in Access Report

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to put the following code in a form, if the report shows a PrdtID=
that starts with ssh then....
If Reports![FillOrder]![PrdtID] = Like "*" & "ssh" & "*" Then
 
Mario

From the code sample, it appears you are trying to base a form on a report.

Forms are based on tables or queries, as are reports. Consider basing your
form on whatever data (table or query) underlies your report.

Or have I misunderstood?

--
Regards

Jeff Boyce
Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Microsoft Registered Partner
https://partner.microsoft.com/
 
What I am trying to do is to print a report if the [PrdtID] starts with ssh,
the form where I am putting this code is only to choose printer 1 or 2

Jeff Boyce said:
Mario

From the code sample, it appears you are trying to base a form on a report.

Forms are based on tables or queries, as are reports. Consider basing your
form on whatever data (table or query) underlies your report.

Or have I misunderstood?

--
Regards

Jeff Boyce
Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Microsoft Registered Partner
https://partner.microsoft.com/


Mario said:
I need to put the following code in a form, if the report shows a PrdtID=
that starts with ssh then....
If Reports![FillOrder]![PrdtID] = Like "*" & "ssh" & "*" Then
 
Mario

You can choose a printer from the report itself, no need to use an
additional form...

Jeff Boyce
Microsoft Office/Access MVP

Mario said:
What I am trying to do is to print a report if the [PrdtID] starts with
ssh,
the form where I am putting this code is only to choose printer 1 or 2

Jeff Boyce said:
Mario

From the code sample, it appears you are trying to base a form on a
report.

Forms are based on tables or queries, as are reports. Consider basing
your
form on whatever data (table or query) underlies your report.

Or have I misunderstood?

--
Regards

Jeff Boyce
Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Microsoft Registered Partner
https://partner.microsoft.com/


Mario said:
I need to put the following code in a form, if the report shows a
PrdtID=
that starts with ssh then....
If Reports![FillOrder]![PrdtID] = Like "*" & "ssh" & "*" Then
 
Thanks Jeff for your responses but here is the whole explanation:

I have a report named "FillOrder", in that report there is a bunch of
different [PrdtID] that the customers order. We print this "FillOrder" give
it to an order filler and the order gets filled. Some of the products we sell
and filled orders with are shrimps.
I made another FillOrder called "FillOrderShrimp", I want to be able to
print the "FillOrderShrimp" only if the "FillOrder" has any shrimp. All the
types of shrimp that we have the [PrdtID] starts with "ssh" and that is why I
need the code with If Reports![FillOrder]![PrdtID] = Like "*" & "ssh" & "*"
then (print "FillOrderShrimp")

Jeff Boyce said:
Mario

You can choose a printer from the report itself, no need to use an
additional form...

Jeff Boyce
Microsoft Office/Access MVP

Mario said:
What I am trying to do is to print a report if the [PrdtID] starts with
ssh,
the form where I am putting this code is only to choose printer 1 or 2

Jeff Boyce said:
Mario

From the code sample, it appears you are trying to base a form on a
report.

Forms are based on tables or queries, as are reports. Consider basing
your
form on whatever data (table or query) underlies your report.

Or have I misunderstood?

--
Regards

Jeff Boyce
Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Microsoft Registered Partner
https://partner.microsoft.com/


I need to put the following code in a form, if the report shows a
PrdtID=
that starts with ssh then....
If Reports![FillOrder]![PrdtID] = Like "*" & "ssh" & "*" Then
 
Mario

Please check into the File|Print selection on your report ... you should be
able to select a printer there. Or is there a reason you are not able to
select a printer from within the report?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Mario said:
Thanks Jeff for your responses but here is the whole explanation:

I have a report named "FillOrder", in that report there is a bunch of
different [PrdtID] that the customers order. We print this "FillOrder"
give
it to an order filler and the order gets filled. Some of the products we
sell
and filled orders with are shrimps.
I made another FillOrder called "FillOrderShrimp", I want to be able to
print the "FillOrderShrimp" only if the "FillOrder" has any shrimp. All
the
types of shrimp that we have the [PrdtID] starts with "ssh" and that is
why I
need the code with If Reports![FillOrder]![PrdtID] = Like "*" & "ssh" &
"*"
then (print "FillOrderShrimp")

Jeff Boyce said:
Mario

You can choose a printer from the report itself, no need to use an
additional form...

Jeff Boyce
Microsoft Office/Access MVP

Mario said:
What I am trying to do is to print a report if the [PrdtID] starts with
ssh,
the form where I am putting this code is only to choose printer 1 or 2

:

Mario

From the code sample, it appears you are trying to base a form on a
report.

Forms are based on tables or queries, as are reports. Consider basing
your
form on whatever data (table or query) underlies your report.

Or have I misunderstood?

--
Regards

Jeff Boyce
Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Microsoft Registered Partner
https://partner.microsoft.com/


I need to put the following code in a form, if the report shows a
PrdtID=
that starts with ssh then....
If Reports![FillOrder]![PrdtID] = Like "*" & "ssh" & "*" Then
 
Is not about selecting a printer. Thanks for your time.

Jeff Boyce said:
Mario

Please check into the File|Print selection on your report ... you should be
able to select a printer there. Or is there a reason you are not able to
select a printer from within the report?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Mario said:
Thanks Jeff for your responses but here is the whole explanation:

I have a report named "FillOrder", in that report there is a bunch of
different [PrdtID] that the customers order. We print this "FillOrder"
give
it to an order filler and the order gets filled. Some of the products we
sell
and filled orders with are shrimps.
I made another FillOrder called "FillOrderShrimp", I want to be able to
print the "FillOrderShrimp" only if the "FillOrder" has any shrimp. All
the
types of shrimp that we have the [PrdtID] starts with "ssh" and that is
why I
need the code with If Reports![FillOrder]![PrdtID] = Like "*" & "ssh" &
"*"
then (print "FillOrderShrimp")

Jeff Boyce said:
Mario

You can choose a printer from the report itself, no need to use an
additional form...

Jeff Boyce
Microsoft Office/Access MVP

What I am trying to do is to print a report if the [PrdtID] starts with
ssh,
the form where I am putting this code is only to choose printer 1 or 2

:

Mario

From the code sample, it appears you are trying to base a form on a
report.

Forms are based on tables or queries, as are reports. Consider basing
your
form on whatever data (table or query) underlies your report.

Or have I misunderstood?

--
Regards

Jeff Boyce
Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Microsoft Registered Partner
https://partner.microsoft.com/


I need to put the following code in a form, if the report shows a
PrdtID=
that starts with ssh then....
If Reports![FillOrder]![PrdtID] = Like "*" & "ssh" & "*" Then
 
Mario

Sorry I wasn't able to be of help. I was confused by your post "What I am
trying to do is to print a report if the [PrdtID] starts with ssh, the form
where I am putting this code is only to choose printer 1 or 2" and your
subsequent "(print "FillOrderShrimp")", and thought you were trying to
figure out how to print something.

Perhaps I have misunderstood because we aren't using the same definitions
for terms.

If you want to know if there are any shrimp in the report, look first in the
query that feeds the report.

You could use "Like *ssh*" (without the quotes) as a criterion in the query.

--
Regards

Jeff Boyce
Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Microsoft Registered Partner
https://partner.microsoft.com/



Mario said:
Is not about selecting a printer. Thanks for your time.

Jeff Boyce said:
Mario

Please check into the File|Print selection on your report ... you should be
able to select a printer there. Or is there a reason you are not able to
select a printer from within the report?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Mario said:
Thanks Jeff for your responses but here is the whole explanation:

I have a report named "FillOrder", in that report there is a bunch of
different [PrdtID] that the customers order. We print this "FillOrder"
give
it to an order filler and the order gets filled. Some of the products we
sell
and filled orders with are shrimps.
I made another FillOrder called "FillOrderShrimp", I want to be able to
print the "FillOrderShrimp" only if the "FillOrder" has any shrimp. All
the
types of shrimp that we have the [PrdtID] starts with "ssh" and that is
why I
need the code with If Reports![FillOrder]![PrdtID] = Like "*" & "ssh" &
"*"
then (print "FillOrderShrimp")

:

Mario

You can choose a printer from the report itself, no need to use an
additional form...

Jeff Boyce
Microsoft Office/Access MVP

What I am trying to do is to print a report if the [PrdtID] starts with
ssh,
the form where I am putting this code is only to choose printer 1 or 2

:

Mario

From the code sample, it appears you are trying to base a form on a
report.

Forms are based on tables or queries, as are reports. Consider basing
your
form on whatever data (table or query) underlies your report.

Or have I misunderstood?

--
Regards

Jeff Boyce
Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Microsoft Registered Partner
https://partner.microsoft.com/


I need to put the following code in a form, if the report shows a
PrdtID=
that starts with ssh then....
If Reports![FillOrder]![PrdtID] = Like "*" & "ssh" & "*" Then
 
The FillOrderShrimp report allready has your suggestion ( "Like *ssh*").

I need the code that if "FillOrder" report has a [PrdtID] that starts with
"ssh" to then print "FillOrderShrimp"

Mario said:
Is not about selecting a printer. Thanks for your time.

Jeff Boyce said:
Mario

Please check into the File|Print selection on your report ... you should be
able to select a printer there. Or is there a reason you are not able to
select a printer from within the report?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Mario said:
Thanks Jeff for your responses but here is the whole explanation:

I have a report named "FillOrder", in that report there is a bunch of
different [PrdtID] that the customers order. We print this "FillOrder"
give
it to an order filler and the order gets filled. Some of the products we
sell
and filled orders with are shrimps.
I made another FillOrder called "FillOrderShrimp", I want to be able to
print the "FillOrderShrimp" only if the "FillOrder" has any shrimp. All
the
types of shrimp that we have the [PrdtID] starts with "ssh" and that is
why I
need the code with If Reports![FillOrder]![PrdtID] = Like "*" & "ssh" &
"*"
then (print "FillOrderShrimp")

:

Mario

You can choose a printer from the report itself, no need to use an
additional form...

Jeff Boyce
Microsoft Office/Access MVP

What I am trying to do is to print a report if the [PrdtID] starts with
ssh,
the form where I am putting this code is only to choose printer 1 or 2

:

Mario

From the code sample, it appears you are trying to base a form on a
report.

Forms are based on tables or queries, as are reports. Consider basing
your
form on whatever data (table or query) underlies your report.

Or have I misunderstood?

--
Regards

Jeff Boyce
Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Microsoft Registered Partner
https://partner.microsoft.com/


I need to put the following code in a form, if the report shows a
PrdtID=
that starts with ssh then....
If Reports![FillOrder]![PrdtID] = Like "*" & "ssh" & "*" Then
 
Mario

I suspect you could add the If() statement to your report's OnFormat event,
and use DoCmd.OpenReport with the 'print now' setting.

--
Regards

Jeff Boyce
Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Microsoft Registered Partner
https://partner.microsoft.com/


Mario said:
The FillOrderShrimp report allready has your suggestion ( "Like *ssh*").

I need the code that if "FillOrder" report has a [PrdtID] that starts with
"ssh" to then print "FillOrderShrimp"

Mario said:
Is not about selecting a printer. Thanks for your time.

Jeff Boyce said:
Mario

Please check into the File|Print selection on your report ... you should be
able to select a printer there. Or is there a reason you are not able to
select a printer from within the report?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Thanks Jeff for your responses but here is the whole explanation:

I have a report named "FillOrder", in that report there is a bunch of
different [PrdtID] that the customers order. We print this "FillOrder"
give
it to an order filler and the order gets filled. Some of the products we
sell
and filled orders with are shrimps.
I made another FillOrder called "FillOrderShrimp", I want to be able to
print the "FillOrderShrimp" only if the "FillOrder" has any shrimp. All
the
types of shrimp that we have the [PrdtID] starts with "ssh" and that is
why I
need the code with If Reports![FillOrder]![PrdtID] = Like "*" & "ssh" &
"*"
then (print "FillOrderShrimp")

:

Mario

You can choose a printer from the report itself, no need to use an
additional form...

Jeff Boyce
Microsoft Office/Access MVP

What I am trying to do is to print a report if the [PrdtID] starts with
ssh,
the form where I am putting this code is only to choose printer 1 or 2

:

Mario

From the code sample, it appears you are trying to base a form on a
report.

Forms are based on tables or queries, as are reports. Consider basing
your
form on whatever data (table or query) underlies your report.

Or have I misunderstood?

--
Regards

Jeff Boyce
Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Microsoft Registered Partner
https://partner.microsoft.com/


I need to put the following code in a form, if the report shows a
PrdtID=
that starts with ssh then....
If Reports![FillOrder]![PrdtID] = Like "*" & "ssh" & "*" Then
 
Back
Top