On print doesn't open report sheet

C

Carl_and_Earl

I have this code:

Private Sub print_Click()
On Error GoTo Err_print

Dim MyWhereCondition As String

MyWhereCondition = "ID= " & Me.ID
DoCmd.OpenReport " Consemne ", acPreview, , MyWhereCondition

Exit_print:
Exit Sub

Err_print:
MsgBox Err.Description
Resume Exit_print
End Sub

That worked perfectly... something happened while changhing some forms. Now
when I press the print button on the form, nothing happens.
The report that the expression reffers to, exists.
There is a printer installed.
 
J

Jim Burke in Novi

1)Make sure the button is still called 'print'.

2) Check to make sure the print button On Click' Event property is still
set. Make sure you see [Event Procedure] there, click on that button and make
sure it goes to that routine. If you don't see that, click on theOn Click
property, select Event Procedure, click on the ellipsis,it should being you
to that routine, and the association (or whatever the proper word is) should
be established. I've had situations where, after making changes to a form (in
my case I know if I went from a non-tabbed form to a tabbed form those
'associations' went away), I had to re-establish those 'links' by going to
each button's On Click property and doing what I said. A compile might
re-establish those 'associations', not sure.

3) If everything still looks OK, set a breakpoint at the statement

MyWhereCondition = "ID= " & Me.ID

and step through to see what it's doing, make sure the variable is set to
what you think it should be, etc.. If it's getting to the OpenReport, it
should either open a report (possibly blank) or give you an error. If it gets
to that statement and does nothing at all, then I don't know what to tell you!
 
L

Linq Adams via AccessMonster.com

You didn't, perchance, change the datatype of you ID field from Numeric to
Text, did you? You code is set up assuming that ID is Numeric.
 
C

Carl_and_Earl

1. Button called print - check!
2. On click event property - check!
3. Event procedure - check!
4. Reasociate - check!
5. Break point? meaning to bypass the MyWhereCondition statement?

Nothing happens... not even a blank report.

Thanks anyway Jim!


Jim Burke in Novi said:
1)Make sure the button is still called 'print'.

2) Check to make sure the print button On Click' Event property is still
set. Make sure you see [Event Procedure] there, click on that button and make
sure it goes to that routine. If you don't see that, click on theOn Click
property, select Event Procedure, click on the ellipsis,it should being you
to that routine, and the association (or whatever the proper word is) should
be established. I've had situations where, after making changes to a form (in
my case I know if I went from a non-tabbed form to a tabbed form those
'associations' went away), I had to re-establish those 'links' by going to
each button's On Click property and doing what I said. A compile might
re-establish those 'associations', not sure.

3) If everything still looks OK, set a breakpoint at the statement

MyWhereCondition = "ID= " & Me.ID

and step through to see what it's doing, make sure the variable is set to
what you think it should be, etc.. If it's getting to the OpenReport, it
should either open a report (possibly blank) or give you an error. If it gets
to that statement and does nothing at all, then I don't know what to tell you!


Carl_and_Earl said:
I have this code:

Private Sub print_Click()
On Error GoTo Err_print

Dim MyWhereCondition As String

MyWhereCondition = "ID= " & Me.ID
DoCmd.OpenReport " Consemne ", acPreview, , MyWhereCondition

Exit_print:
Exit Sub

Err_print:
MsgBox Err.Description
Resume Exit_print
End Sub

That worked perfectly... something happened while changhing some forms. Now
when I press the print button on the form, nothing happens.
The report that the expression reffers to, exists.
There is a printer installed.
 
J

Jim Burke in Novi

I meant put a breakpoint at the first statement in the print button On Click
event proc so that you can go into debug mode. Then step thru statement by
statement to make sure each statement is being executed and check what the
value of the variable is. It's also possible that you have some code in the
report that is being run. For example, the report's On No DAta event proc
could have code in it that simply closes the report without any notification
message if there is no data. But regardless, you need to step through your
code to see exactly what statements are being executed. If it executes the
OpenReport command, you should either get an error message or it should
attempt to open the report. Time to do some debugging. I guess it's possible
that somehow your code is corrupted - you could always try a compact/repair
and a decompile.
Carl_and_Earl said:
1. Button called print - check!
2. On click event property - check!
3. Event procedure - check!
4. Reasociate - check!
5. Break point? meaning to bypass the MyWhereCondition statement?

Nothing happens... not even a blank report.

Thanks anyway Jim!


Jim Burke in Novi said:
1)Make sure the button is still called 'print'.

2) Check to make sure the print button On Click' Event property is still
set. Make sure you see [Event Procedure] there, click on that button and make
sure it goes to that routine. If you don't see that, click on theOn Click
property, select Event Procedure, click on the ellipsis,it should being you
to that routine, and the association (or whatever the proper word is) should
be established. I've had situations where, after making changes to a form (in
my case I know if I went from a non-tabbed form to a tabbed form those
'associations' went away), I had to re-establish those 'links' by going to
each button's On Click property and doing what I said. A compile might
re-establish those 'associations', not sure.

3) If everything still looks OK, set a breakpoint at the statement

MyWhereCondition = "ID= " & Me.ID

and step through to see what it's doing, make sure the variable is set to
what you think it should be, etc.. If it's getting to the OpenReport, it
should either open a report (possibly blank) or give you an error. If it gets
to that statement and does nothing at all, then I don't know what to tell you!


Carl_and_Earl said:
I have this code:

Private Sub print_Click()
On Error GoTo Err_print

Dim MyWhereCondition As String

MyWhereCondition = "ID= " & Me.ID
DoCmd.OpenReport " Consemne ", acPreview, , MyWhereCondition

Exit_print:
Exit Sub

Err_print:
MsgBox Err.Description
Resume Exit_print
End Sub

That worked perfectly... something happened while changhing some forms. Now
when I press the print button on the form, nothing happens.
The report that the expression reffers to, exists.
There is a printer installed.
 
C

Carl_and_Earl

When you fresh install Access 2007 and you open a database, it opens
something like in internet explorer anouncing about active X component being
downloaded asking for your permission.
In this case, Access asks me about enabling scrips or not, or something like
that. But there is more. I have to enable all macros for my print button to
work.
So it was nothing wrong about the code.
Hope that helps other people too.

Thanks.

Jim Burke in Novi said:
I meant put a breakpoint at the first statement in the print button On Click
event proc so that you can go into debug mode. Then step thru statement by
statement to make sure each statement is being executed and check what the
value of the variable is. It's also possible that you have some code in the
report that is being run. For example, the report's On No DAta event proc
could have code in it that simply closes the report without any notification
message if there is no data. But regardless, you need to step through your
code to see exactly what statements are being executed. If it executes the
OpenReport command, you should either get an error message or it should
attempt to open the report. Time to do some debugging. I guess it's possible
that somehow your code is corrupted - you could always try a compact/repair
and a decompile.
Carl_and_Earl said:
1. Button called print - check!
2. On click event property - check!
3. Event procedure - check!
4. Reasociate - check!
5. Break point? meaning to bypass the MyWhereCondition statement?

Nothing happens... not even a blank report.

Thanks anyway Jim!


Jim Burke in Novi said:
1)Make sure the button is still called 'print'.

2) Check to make sure the print button On Click' Event property is still
set. Make sure you see [Event Procedure] there, click on that button and make
sure it goes to that routine. If you don't see that, click on theOn Click
property, select Event Procedure, click on the ellipsis,it should being you
to that routine, and the association (or whatever the proper word is) should
be established. I've had situations where, after making changes to a form (in
my case I know if I went from a non-tabbed form to a tabbed form those
'associations' went away), I had to re-establish those 'links' by going to
each button's On Click property and doing what I said. A compile might
re-establish those 'associations', not sure.

3) If everything still looks OK, set a breakpoint at the statement

MyWhereCondition = "ID= " & Me.ID

and step through to see what it's doing, make sure the variable is set to
what you think it should be, etc.. If it's getting to the OpenReport, it
should either open a report (possibly blank) or give you an error. If it gets
to that statement and does nothing at all, then I don't know what to tell you!


:

I have this code:

Private Sub print_Click()
On Error GoTo Err_print

Dim MyWhereCondition As String

MyWhereCondition = "ID= " & Me.ID
DoCmd.OpenReport " Consemne ", acPreview, , MyWhereCondition

Exit_print:
Exit Sub

Err_print:
MsgBox Err.Description
Resume Exit_print
End Sub

That worked perfectly... something happened while changhing some forms. Now
when I press the print button on the form, nothing happens.
The report that the expression reffers to, exists.
There is a printer installed.
 

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