print from form

J

JIM

Hi, after researching, I think the best way to print a Word document from a
form is with the following code behind an Option Button:

Private Sub Option60_Click()
DoCmd.OpenReport acViewNormal, qryWorkOrders, [RoofPlanLoc] =
Forms!frmWorkOrders![sfrmClientBuildings]!Form![txtRoofPlanLoc]
End Sub

or

Private Sub Option60_Click()
DoCmd.SelectObject acReport, "rptMap/RoofPlans", True
DoCmd.PrintOut
End Sub

But I can't get either to work. What am I missing?
Thanks, JIM
 
J

JIM

Thanks Evi for your input. I have a report that prints a Word document, the
file location is hard coded in a report subroutine. Instead of having data
input person go to a report I thought I could just call the report when
entering data on the form. The command button is on a subform and when
clicked it does nothing at all.

If I run the report on its own it works.
Thanks, JIM

Evi said:
These codes are both printing reports, not Word Documents.
Evi

JIM said:
Hi, after researching, I think the best way to print a Word document from a
form is with the following code behind an Option Button:

Private Sub Option60_Click()
DoCmd.OpenReport acViewNormal, qryWorkOrders, [RoofPlanLoc] =
Forms!frmWorkOrders![sfrmClientBuildings]!Form![txtRoofPlanLoc]
End Sub

or

Private Sub Option60_Click()
DoCmd.SelectObject acReport, "rptMap/RoofPlans", True
DoCmd.PrintOut
End Sub

But I can't get either to work. What am I missing?
Thanks, JIM
 
E

Evi

If you are using an Option Group to select the report, rather than a single
option button, then the code is slightly different because it actually loops
through an array, assigning a value to each one but assuming a single option
button, your first piece of code won't work because it doesn't include the
name of your report after

OpenReport.

Also, I'm a bit concerned about you having a / in your report name - I'm not
sure if that will cause problems to Access because, like &, -, + and = , it
is an Operator. May I suggest that you remove this for now and replace it
once everything else is working and see if it does no harm.
I'm going to assume that there is a control in the subform of your current
form that contains the value for RoofPlanLoc which you want to filter by
clicking on the Option button in your main form.
I will also assume that RoofPlanLoc is a number (if it is text, the last bit
of the code will be slightly different)
Your code can now read like this:


DoCmd.OpenReport "rptMapRoofPlans", acPreview,,"[RoofPlanLoc]=" &
Me.[sfrmClientBuildings].Form.[txtRoofPlanLoc]


Note the 2 commas after acPreview and the quote marks around the literal
part of the "Where" condition.

Evi


JIM said:
Thanks Evi for your input. I have a report that prints a Word document, the
file location is hard coded in a report subroutine. Instead of having data
input person go to a report I thought I could just call the report when
entering data on the form. The command button is on a subform and when
clicked it does nothing at all.

If I run the report on its own it works.
Thanks, JIM

Evi said:
These codes are both printing reports, not Word Documents.
Evi

JIM said:
Hi, after researching, I think the best way to print a Word document
from
a
form is with the following code behind an Option Button:

Private Sub Option60_Click()
DoCmd.OpenReport acViewNormal, qryWorkOrders, [RoofPlanLoc] =
Forms!frmWorkOrders![sfrmClientBuildings]!Form![txtRoofPlanLoc]
End Sub

or

Private Sub Option60_Click()
DoCmd.SelectObject acReport, "rptMap/RoofPlans", True
DoCmd.PrintOut
End Sub

But I can't get either to work. What am I missing?
Thanks, JIM
 
J

JIM

Thanks Evi for the input. My code now looks like this (my field is text):

Private Sub Option60_Click()
DoCmd.OpenReport "rptMapRoofPlans", acPreview, , "[RoofPlanLoc] =' " &
Me![sfrmClientBuildings]!Form![txtRoofPlanLoc] & " '"
End Sub

and still nothing is happening. Is the field supposed to be the name of the
control, as in txtRoofPlanLoc, or is it the control source? Though I've
tried it both ways and either way there is no response.
Thanks, JIM


Evi said:
If you are using an Option Group to select the report, rather than a single
option button, then the code is slightly different because it actually loops
through an array, assigning a value to each one but assuming a single option
button, your first piece of code won't work because it doesn't include the
name of your report after

OpenReport.

Also, I'm a bit concerned about you having a / in your report name - I'm not
sure if that will cause problems to Access because, like &, -, + and = , it
is an Operator. May I suggest that you remove this for now and replace it
once everything else is working and see if it does no harm.
I'm going to assume that there is a control in the subform of your current
form that contains the value for RoofPlanLoc which you want to filter by
clicking on the Option button in your main form.
I will also assume that RoofPlanLoc is a number (if it is text, the last bit
of the code will be slightly different)
Your code can now read like this:


DoCmd.OpenReport "rptMapRoofPlans", acPreview,,"[RoofPlanLoc]=" &
Me.[sfrmClientBuildings].Form.[txtRoofPlanLoc]


Note the 2 commas after acPreview and the quote marks around the literal
part of the "Where" condition.

Evi


JIM said:
Thanks Evi for your input. I have a report that prints a Word document, the
file location is hard coded in a report subroutine. Instead of having data
input person go to a report I thought I could just call the report when
entering data on the form. The command button is on a subform and when
clicked it does nothing at all.

If I run the report on its own it works.
Thanks, JIM

Evi said:
These codes are both printing reports, not Word Documents.
Evi

Hi, after researching, I think the best way to print a Word document from
a
form is with the following code behind an Option Button:

Private Sub Option60_Click()
DoCmd.OpenReport acViewNormal, qryWorkOrders, [RoofPlanLoc] =
Forms!frmWorkOrders![sfrmClientBuildings]!Form![txtRoofPlanLoc]
End Sub

or

Private Sub Option60_Click()
DoCmd.SelectObject acReport, "rptMap/RoofPlans", True
DoCmd.PrintOut
End Sub

But I can't get either to work. What am I missing?
Thanks, JIM
 
E

Evi

It's getting those darned quote marks right that are causing the problem :)

If your form contains a text box called RoofPlanLoc then that bit is fine.

if RoofPlanLoc is a text field then your code should read

DoCmd.OpenReport "rptMapRoofPlans", acPreview, , "[RoofPlanLoc] =""" &
Me.[sfrmClientBuildings].Form.[txtRoofPlanLoc] & """"

that's 3 quotemarks before the first & and 4 quotemarks after the last &

Make sure in Properties, by clicking on your subform in the Main form's
Design View, that it is actually called sfrmClientBuildings - it's name as a
control in a main form can be different from the name you see in the
database window.

Just one thing. txtRoofPlanLoc is actually a text box, isn't it? It's not a
combo box, is it? The reason I ask, is because the item which a combo shows
isn't always its value.
Evi

JIM said:
Thanks Evi for the input. My code now looks like this (my field is text):

Private Sub Option60_Click()
DoCmd.OpenReport "rptMapRoofPlans", acPreview, , "[RoofPlanLoc] =' " &
Me![sfrmClientBuildings]!Form![txtRoofPlanLoc] & " '"
End Sub

and still nothing is happening. Is the field supposed to be the name of the
control, as in txtRoofPlanLoc, or is it the control source? Though I've
tried it both ways and either way there is no response.
Thanks, JIM


Evi said:
If you are using an Option Group to select the report, rather than a single
option button, then the code is slightly different because it actually loops
through an array, assigning a value to each one but assuming a single option
button, your first piece of code won't work because it doesn't include the
name of your report after

OpenReport.

Also, I'm a bit concerned about you having a / in your report name - I'm not
sure if that will cause problems to Access because, like &, -, + and = , it
is an Operator. May I suggest that you remove this for now and replace it
once everything else is working and see if it does no harm.
I'm going to assume that there is a control in the subform of your current
form that contains the value for RoofPlanLoc which you want to filter by
clicking on the Option button in your main form.
I will also assume that RoofPlanLoc is a number (if it is text, the last bit
of the code will be slightly different)
Your code can now read like this:


DoCmd.OpenReport "rptMapRoofPlans", acPreview,,"[RoofPlanLoc]=" &
Me.[sfrmClientBuildings].Form.[txtRoofPlanLoc]


Note the 2 commas after acPreview and the quote marks around the literal
part of the "Where" condition.

Evi


JIM said:
Thanks Evi for your input. I have a report that prints a Word
document,
the
file location is hard coded in a report subroutine. Instead of having data
input person go to a report I thought I could just call the report when
entering data on the form. The command button is on a subform and when
clicked it does nothing at all.

If I run the report on its own it works.
Thanks, JIM

:

These codes are both printing reports, not Word Documents.
Evi

Hi, after researching, I think the best way to print a Word
document
from
a
form is with the following code behind an Option Button:

Private Sub Option60_Click()
DoCmd.OpenReport acViewNormal, qryWorkOrders, [RoofPlanLoc] =
Forms!frmWorkOrders![sfrmClientBuildings]!Form![txtRoofPlanLoc]
End Sub

or

Private Sub Option60_Click()
DoCmd.SelectObject acReport, "rptMap/RoofPlans", True
DoCmd.PrintOut
End Sub

But I can't get either to work. What am I missing?
Thanks, JIM
 
J

JIM

Evi, my code now looks as you suggested but playing around with it still has
produced nothing. My code now looks like this.
Private Sub Option60_Click()
DoCmd.OpenReport "rptMapRoofPlans", acPreview, , "[RoofPlanLoc] =""" &
Me![sfrmClientBuildings]!Form![txtRoofPlanLoc] & """"
End Sub
Is my code ok?
Thanks, JIM

Evi said:
It's getting those darned quote marks right that are causing the problem :)

If your form contains a text box called RoofPlanLoc then that bit is fine.

if RoofPlanLoc is a text field then your code should read

DoCmd.OpenReport "rptMapRoofPlans", acPreview, , "[RoofPlanLoc] =""" &
Me.[sfrmClientBuildings].Form.[txtRoofPlanLoc] & """"

that's 3 quotemarks before the first & and 4 quotemarks after the last &

Make sure in Properties, by clicking on your subform in the Main form's
Design View, that it is actually called sfrmClientBuildings - it's name as a
control in a main form can be different from the name you see in the
database window.

Just one thing. txtRoofPlanLoc is actually a text box, isn't it? It's not a
combo box, is it? The reason I ask, is because the item which a combo shows
isn't always its value.
Evi

JIM said:
Thanks Evi for the input. My code now looks like this (my field is text):

Private Sub Option60_Click()
DoCmd.OpenReport "rptMapRoofPlans", acPreview, , "[RoofPlanLoc] =' " &
Me![sfrmClientBuildings]!Form![txtRoofPlanLoc] & " '"
End Sub

and still nothing is happening. Is the field supposed to be the name of the
control, as in txtRoofPlanLoc, or is it the control source? Though I've
tried it both ways and either way there is no response.
Thanks, JIM


Evi said:
If you are using an Option Group to select the report, rather than a single
option button, then the code is slightly different because it actually loops
through an array, assigning a value to each one but assuming a single option
button, your first piece of code won't work because it doesn't include the
name of your report after

OpenReport.

Also, I'm a bit concerned about you having a / in your report name - I'm not
sure if that will cause problems to Access because, like &, -, + and = , it
is an Operator. May I suggest that you remove this for now and replace it
once everything else is working and see if it does no harm.
I'm going to assume that there is a control in the subform of your current
form that contains the value for RoofPlanLoc which you want to filter by
clicking on the Option button in your main form.
I will also assume that RoofPlanLoc is a number (if it is text, the last bit
of the code will be slightly different)
Your code can now read like this:


DoCmd.OpenReport "rptMapRoofPlans", acPreview,,"[RoofPlanLoc]=" &
Me.[sfrmClientBuildings].Form.[txtRoofPlanLoc]


Note the 2 commas after acPreview and the quote marks around the literal
part of the "Where" condition.

Evi


Thanks Evi for your input. I have a report that prints a Word document,
the
file location is hard coded in a report subroutine. Instead of having
data
input person go to a report I thought I could just call the report when
entering data on the form. The command button is on a subform and when
clicked it does nothing at all.

If I run the report on its own it works.
Thanks, JIM

:

These codes are both printing reports, not Word Documents.
Evi

Hi, after researching, I think the best way to print a Word document
from
a
form is with the following code behind an Option Button:

Private Sub Option60_Click()
DoCmd.OpenReport acViewNormal, qryWorkOrders, [RoofPlanLoc] =
Forms!frmWorkOrders![sfrmClientBuildings]!Form![txtRoofPlanLoc]
End Sub

or

Private Sub Option60_Click()
DoCmd.SelectObject acReport, "rptMap/RoofPlans", True
DoCmd.PrintOut
End Sub

But I can't get either to work. What am I missing?
Thanks, JIM
 
E

Evi

So to check, your text box (not combo box) is called txtRoofPlanLoc.
It contains a text field.
Your subform control, when you go to it in Design View of the Main form and
look at its Properties, has the Name sfrmClientBuildings
Your report rptMapRoofPlans, contains the text field RoofPlanLoc


One last thing is your control part of an Option Group? If yes, then the
code is slightly different.


Evi



JIM said:
Evi, my code now looks as you suggested but playing around with it still has
produced nothing. My code now looks like this.
Private Sub Option60_Click()
DoCmd.OpenReport "rptMapRoofPlans", acPreview, , "[RoofPlanLoc] =""" &
Me![sfrmClientBuildings]!Form![txtRoofPlanLoc] & """"
End Sub
Is my code ok?
Thanks, JIM

Evi said:
It's getting those darned quote marks right that are causing the problem :)

If your form contains a text box called RoofPlanLoc then that bit is fine.

if RoofPlanLoc is a text field then your code should read

DoCmd.OpenReport "rptMapRoofPlans", acPreview, , "[RoofPlanLoc] =""" &
Me.[sfrmClientBuildings].Form.[txtRoofPlanLoc] & """"

that's 3 quotemarks before the first & and 4 quotemarks after the last &

Make sure in Properties, by clicking on your subform in the Main form's
Design View, that it is actually called sfrmClientBuildings - it's name as a
control in a main form can be different from the name you see in the
database window.

Just one thing. txtRoofPlanLoc is actually a text box, isn't it? It's not a
combo box, is it? The reason I ask, is because the item which a combo shows
isn't always its value.
Evi

JIM said:
Thanks Evi for the input. My code now looks like this (my field is text):

Private Sub Option60_Click()
DoCmd.OpenReport "rptMapRoofPlans", acPreview, , "[RoofPlanLoc] =' " &
Me![sfrmClientBuildings]!Form![txtRoofPlanLoc] & " '"
End Sub

and still nothing is happening. Is the field supposed to be the name
of
the
control, as in txtRoofPlanLoc, or is it the control source? Though I've
tried it both ways and either way there is no response.
Thanks, JIM


:

If you are using an Option Group to select the report, rather than a single
option button, then the code is slightly different because it
actually
loops
through an array, assigning a value to each one but assuming a
single
option
button, your first piece of code won't work because it doesn't
include
the
name of your report after

OpenReport.

Also, I'm a bit concerned about you having a / in your report name -
I'm
not
sure if that will cause problems to Access because, like &, -, + and
= ,
it
is an Operator. May I suggest that you remove this for now and
replace
it
once everything else is working and see if it does no harm.
I'm going to assume that there is a control in the subform of your current
form that contains the value for RoofPlanLoc which you want to filter by
clicking on the Option button in your main form.
I will also assume that RoofPlanLoc is a number (if it is text, the
last
bit
of the code will be slightly different)
Your code can now read like this:


DoCmd.OpenReport "rptMapRoofPlans", acPreview,,"[RoofPlanLoc]=" &
Me.[sfrmClientBuildings].Form.[txtRoofPlanLoc]


Note the 2 commas after acPreview and the quote marks around the literal
part of the "Where" condition.

Evi


Thanks Evi for your input. I have a report that prints a Word document,
the
file location is hard coded in a report subroutine. Instead of having
data
input person go to a report I thought I could just call the report when
entering data on the form. The command button is on a subform and when
clicked it does nothing at all.

If I run the report on its own it works.
Thanks, JIM

:

These codes are both printing reports, not Word Documents.
Evi

Hi, after researching, I think the best way to print a Word document
from
a
form is with the following code behind an Option Button:

Private Sub Option60_Click()
DoCmd.OpenReport acViewNormal, qryWorkOrders, [RoofPlanLoc] =
Forms!frmWorkOrders![sfrmClientBuildings]!Form![txtRoofPlanLoc]
End Sub

or

Private Sub Option60_Click()
DoCmd.SelectObject acReport, "rptMap/RoofPlans", True
DoCmd.PrintOut
End Sub

But I can't get either to work. What am I missing?
Thanks, JIM
 
J

JIM

The control is not part of an option group it is an option button. But I
think my report coding is the problem. You said my report must contain a
text field "RoofPlanLoc" - it does not. On open report I have this code:

Private Sub Report_Open(Cancel As Integer)
Dim WordObj As Object
Set WordObj = CreateObject("Word.Application")
WordObj.Documents.Open "L:\Plans\Xcel\Xcel-Greeley.doc"
WordObj.PrintOut Background:=False
WordObj.Quit
Set WordObj = Nothing
End Sub

It works on its own, but when I call it from the form there is not response.
Thanks, JIM

Evi said:
So to check, your text box (not combo box) is called txtRoofPlanLoc.
It contains a text field.
Your subform control, when you go to it in Design View of the Main form and
look at its Properties, has the Name sfrmClientBuildings
Your report rptMapRoofPlans, contains the text field RoofPlanLoc


One last thing is your control part of an Option Group? If yes, then the
code is slightly different.


Evi



JIM said:
Evi, my code now looks as you suggested but playing around with it still has
produced nothing. My code now looks like this.
Private Sub Option60_Click()
DoCmd.OpenReport "rptMapRoofPlans", acPreview, , "[RoofPlanLoc] =""" &
Me![sfrmClientBuildings]!Form![txtRoofPlanLoc] & """"
End Sub
Is my code ok?
Thanks, JIM

Evi said:
It's getting those darned quote marks right that are causing the problem :)

If your form contains a text box called RoofPlanLoc then that bit is fine.

if RoofPlanLoc is a text field then your code should read

DoCmd.OpenReport "rptMapRoofPlans", acPreview, , "[RoofPlanLoc] =""" &
Me.[sfrmClientBuildings].Form.[txtRoofPlanLoc] & """"

that's 3 quotemarks before the first & and 4 quotemarks after the last &

Make sure in Properties, by clicking on your subform in the Main form's
Design View, that it is actually called sfrmClientBuildings - it's name as a
control in a main form can be different from the name you see in the
database window.

Just one thing. txtRoofPlanLoc is actually a text box, isn't it? It's not a
combo box, is it? The reason I ask, is because the item which a combo shows
isn't always its value.
Evi

Thanks Evi for the input. My code now looks like this (my field is text):

Private Sub Option60_Click()
DoCmd.OpenReport "rptMapRoofPlans", acPreview, , "[RoofPlanLoc] =' " &
Me![sfrmClientBuildings]!Form![txtRoofPlanLoc] & " '"
End Sub

and still nothing is happening. Is the field supposed to be the name of
the
control, as in txtRoofPlanLoc, or is it the control source? Though I've
tried it both ways and either way there is no response.
Thanks, JIM


:

If you are using an Option Group to select the report, rather than a
single
option button, then the code is slightly different because it actually
loops
through an array, assigning a value to each one but assuming a single
option
button, your first piece of code won't work because it doesn't include
the
name of your report after

OpenReport.

Also, I'm a bit concerned about you having a / in your report name - I'm
not
sure if that will cause problems to Access because, like &, -, + and = ,
it
is an Operator. May I suggest that you remove this for now and replace
it
once everything else is working and see if it does no harm.
I'm going to assume that there is a control in the subform of your
current
form that contains the value for RoofPlanLoc which you want to filter by
clicking on the Option button in your main form.
I will also assume that RoofPlanLoc is a number (if it is text, the last
bit
of the code will be slightly different)
Your code can now read like this:


DoCmd.OpenReport "rptMapRoofPlans", acPreview,,"[RoofPlanLoc]=" &
Me.[sfrmClientBuildings].Form.[txtRoofPlanLoc]


Note the 2 commas after acPreview and the quote marks around the literal
part of the "Where" condition.

Evi


Thanks Evi for your input. I have a report that prints a Word
document,
the
file location is hard coded in a report subroutine. Instead of having
data
input person go to a report I thought I could just call the report
when
entering data on the form. The command button is on a subform and
when
clicked it does nothing at all.

If I run the report on its own it works.
Thanks, JIM

:

These codes are both printing reports, not Word Documents.
Evi

Hi, after researching, I think the best way to print a Word
document
from
a
form is with the following code behind an Option Button:

Private Sub Option60_Click()
DoCmd.OpenReport acViewNormal, qryWorkOrders, [RoofPlanLoc] =
Forms!frmWorkOrders![sfrmClientBuildings]!Form![txtRoofPlanLoc]
End Sub

or

Private Sub Option60_Click()
DoCmd.SelectObject acReport, "rptMap/RoofPlans", True
DoCmd.PrintOut
End Sub

But I can't get either to work. What am I missing?
Thanks, JIM
 
E

Evi

I think this could be the problem then. Your code is trying to filter the
report by RoofPlanLoc. You could always put it in as an Invisible control,
if you don't want to see it.
Take out the OpenReport code just for now until you have fixed the problem,
then put it back and see if there is a problem with that
Evi
JIM said:
The control is not part of an option group it is an option button. But I
think my report coding is the problem. You said my report must contain a
text field "RoofPlanLoc" - it does not. On open report I have this code:

Private Sub Report_Open(Cancel As Integer)
Dim WordObj As Object
Set WordObj = CreateObject("Word.Application")
WordObj.Documents.Open "L:\Plans\Xcel\Xcel-Greeley.doc"
WordObj.PrintOut Background:=False
WordObj.Quit
Set WordObj = Nothing
End Sub

It works on its own, but when I call it from the form there is not response.
Thanks, JIM

Evi said:
So to check, your text box (not combo box) is called txtRoofPlanLoc.
It contains a text field.
Your subform control, when you go to it in Design View of the Main form and
look at its Properties, has the Name sfrmClientBuildings
Your report rptMapRoofPlans, contains the text field RoofPlanLoc


One last thing is your control part of an Option Group? If yes, then the
code is slightly different.


Evi



JIM said:
Evi, my code now looks as you suggested but playing around with it
still
has
produced nothing. My code now looks like this.
Private Sub Option60_Click()
DoCmd.OpenReport "rptMapRoofPlans", acPreview, , "[RoofPlanLoc] =""" &
Me![sfrmClientBuildings]!Form![txtRoofPlanLoc] & """"
End Sub
Is my code ok?
Thanks, JIM

:

It's getting those darned quote marks right that are causing the
problem
:)
If your form contains a text box called RoofPlanLoc then that bit is fine.

if RoofPlanLoc is a text field then your code should read

DoCmd.OpenReport "rptMapRoofPlans", acPreview, , "[RoofPlanLoc] =""" &
Me.[sfrmClientBuildings].Form.[txtRoofPlanLoc] & """"

that's 3 quotemarks before the first & and 4 quotemarks after the last &

Make sure in Properties, by clicking on your subform in the Main form's
Design View, that it is actually called sfrmClientBuildings - it's
name
as a
control in a main form can be different from the name you see in the
database window.

Just one thing. txtRoofPlanLoc is actually a text box, isn't it?
It's
not a
combo box, is it? The reason I ask, is because the item which a
combo
shows
isn't always its value.
Evi

Thanks Evi for the input. My code now looks like this (my field
is
text):
Private Sub Option60_Click()
DoCmd.OpenReport "rptMapRoofPlans", acPreview, , "[RoofPlanLoc] =' " &
Me![sfrmClientBuildings]!Form![txtRoofPlanLoc] & " '"
End Sub

and still nothing is happening. Is the field supposed to be the
name
of
the
control, as in txtRoofPlanLoc, or is it the control source?
Though
I've
tried it both ways and either way there is no response.
Thanks, JIM


:

If you are using an Option Group to select the report, rather than a
single
option button, then the code is slightly different because it actually
loops
through an array, assigning a value to each one but assuming a single
option
button, your first piece of code won't work because it doesn't include
the
name of your report after

OpenReport.

Also, I'm a bit concerned about you having a / in your report
name -
I'm
not
sure if that will cause problems to Access because, like &, -, +
and
= ,
it
is an Operator. May I suggest that you remove this for now and replace
it
once everything else is working and see if it does no harm.
I'm going to assume that there is a control in the subform of your
current
form that contains the value for RoofPlanLoc which you want to filter by
clicking on the Option button in your main form.
I will also assume that RoofPlanLoc is a number (if it is text,
the
last
bit
of the code will be slightly different)
Your code can now read like this:


DoCmd.OpenReport "rptMapRoofPlans", acPreview,,"[RoofPlanLoc]=" &
Me.[sfrmClientBuildings].Form.[txtRoofPlanLoc]


Note the 2 commas after acPreview and the quote marks around the literal
part of the "Where" condition.

Evi


Thanks Evi for your input. I have a report that prints a Word
document,
the
file location is hard coded in a report subroutine. Instead
of
having
data
input person go to a report I thought I could just call the report
when
entering data on the form. The command button is on a subform and
when
clicked it does nothing at all.

If I run the report on its own it works.
Thanks, JIM

:

These codes are both printing reports, not Word Documents.
Evi

Hi, after researching, I think the best way to print a Word
document
from
a
form is with the following code behind an Option Button:

Private Sub Option60_Click()
DoCmd.OpenReport acViewNormal, qryWorkOrders, [RoofPlanLoc] =
Forms!frmWorkOrders![sfrmClientBuildings]!Form![txtRoofPlanLoc]
End Sub

or

Private Sub Option60_Click()
DoCmd.SelectObject acReport, "rptMap/RoofPlans", True
DoCmd.PrintOut
End Sub

But I can't get either to work. What am I missing?
Thanks, JIM
 

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