By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,248 Members | 1,104 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,248 IT Pros & Developers. It's quick & easy.

MS Access Calendar Error when Printing

RockKandee
P: 89
Hi,

I am getting an error message when trying to print.

I am using the MS access calendar found here:

http://bytes.com/topic/access/answer...ccess-calendar

I have Windows 8 and Office/Access 2013. I am using this in a desk top database and would like to transfer it to a web database in the future.

I want to print this calendar. I haven't found a way to make a report so I tried to print the form. I get an error message when I select print and the same error message each time I open a table (or anything else) from then on. Once I close and reopen the database, all is good again until I try to print.

Error message:
Error inPopulateCalendar()
Invalid use of Null

Is there a solution for this?

Thanks for your time.
Dec 8 '13 #1

✓ answered by RockKandee

Solution

Although my original goal was to eliminate the error message, my ultimate goal was to print the calendar month displayed without any error occurring for the user.

The error message occurs when selecting print preview. Clicking ok on the error box will make the error message go away and print preview (with the data) will display. So setting margins at this time isn't a problem.

Closing the print preview will result in the error message pop up again and clicking ok in the error box will result in closing the view and returning to the calendar form.

Originally, the error would continue to occur when opening tables. Closing and re-opening the database fixed this. This no longer happens for me and I have no idea why.

Once margins are set, to avoid this error message, do not use print preview.

Providing a print button for the user will discourage use of print preview.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.PrintOut Application.Printers("HP Deskjet 3050A J611 series (Copy 1)").Orientation = acPRORLandscape
Using this code worked. No errors. However, this prints all pages. There are 4 pages total. Page 1 is the calendar. Page 2 includes the controls next to the calendar such as the print command button. I re-sized the calendar to make it as larger as possible to fit on one page and still fit on the computer screen. Changing the settings for the print button to be visible on screen only, makes page 2 blank for printing. I am assuming page 3 and 4 are due to the bottom of the calendar form exceeding page 1 and 2 a little bit. These pages are blank also.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunCommand acCmdPrint
Using this code will allow for selecting which pages to print. If the user knows to set the print range to 1 page.

I wanted an explanation free, think free, error free alternative.

Expand|Select|Wrap|Line Numbers
  1. Forms("CalendarAll").Printer.Orientation = acPRORLandscape
  2. DoCmd.PrintOut , 1, 1, acLow, 1, False
Using this code with the print button On Click will result in printing only the first page of the form.

So this is the winner!

Thank you for the time and help.

Share this Question
Share on Google+
10 Replies


ADezii
Expert 5K+
P: 8,638
Have you tried:
Expand|Select|Wrap|Line Numbers
  1. Application.Printers("Printer Name").Orientation = acPRORLandscape
  2.   DoCmd.PrintOut
  3. Application.Printers("Printer Name").Orientation = acPRORPortrait
Dec 8 '13 #2

RockKandee
P: 89
I am very, VERY new at this. No I hadn't tried but I have now - I think.

I am not sure what I was supposed to do with this code. I assumed I should pick either the landscape or portrait, not use both, though I did try with both. I used the printer name exactly how it is displayed on the printer drop down where I choose which printer to print with. I made a command button on the calendar form and entered the below code in the on click.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.PrintOut "Application.Printers("HP Deskjet 3050A J611 series (Copy 1)").Orientation = acPRORLandscape"
I followed examples of other code to the best of my understanding. I received the following error

Compile Error: Syntax error

Not sure if the code has errors because of the spaces in the printer name and if so, I don't know what to do.

Thanks
Dec 9 '13 #3

P: 17
Remove the first and the last ", like this:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.PrintOut Application.Printers("HP Deskjet 3050A J611 series (Copy 1)").Orientation = acPRORLandscape
Dec 9 '13 #4

RockKandee
P: 89
I removed the first and last " like this

Expand|Select|Wrap|Line Numbers
  1. DoCmd.PrintOut Application.Printers("HP Deskjet 3050A J611 series (Copy 1)").Orientation = acPRORLandscape
I no longer receive an error message - Thank you.

It is going directly to print and printing 4 pages. I do not want 4 pages printed. I only want to print the current page. The print message that pops up after I click the print button flashes too fast for reading. Maybe I need to go to print preview instead of directly to print.


I found this in another post and tried it.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunCommand acCmdPrintPreview
This results in giving me the original error message...

Error message:
Error inPopulateCalendar()
Invalid use of Null
Dec 9 '13 #5

P: 17
The error is caused by the Form_Activate procedure. But printing the form is to no use anyway, since it is unbound, all fields will be empty in the printout. You will need to design a report based on the table which holds the data you want.

Maybe it would be easier for you to try another calendar, like this one, which has a nice report included.
Dec 9 '13 #6

RockKandee
P: 89
Thanks for the link. That looks like a great calendar for anyone looking to replace their Outlook Calendar. I am sure I will find a use for it in the future.

Now back to the original calendar....If I print the calendar form, it DOES display the data. The error message is occurring with print preview only. No one else should need to preview, so I can live with the error.

I would like to avoid printing 4 pages though. Is their code to add to the print command so that only page 1 will print?

Thanks
Dec 10 '13 #7

ADezii
Expert 5K+
P: 8,638
I use a primitive, but very effective means to Print the Access Calendar as long as there is no data that extends vertically beyond the Date Blocks.
  1. Make sure that the Calendar Form is the Active Window and is centered.
  2. Perform a Screen Capture of the Active Window (Calendar) via ALT+PRTSCRN.
  3. Open Microsoft Word, set the Margins to .5 all around and Landscape Orientation.
  4. Center the Cursor.
  5. Paste the Image of the Active Window (Calendar) from the Clipboard (CTRL+V).
  6. Of course I could use Automation Code to perform the above but it seems hardly worth it since the operation only takes a few seconds and the results are great.
Dec 10 '13 #8

P: 17
If I print the calendar form, it DOES display the data.
That's right, if you do a direct print. Printpreview will interfere with the data population, and give you the error you see and no data in the report.

This will open the print dialog (Access 2003, hopefully in 2013 also), where you can adjust margins so the form will fit on one page:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunCommand acCmdPrint
Dec 10 '13 #9

RockKandee
P: 89
I would rather not have users go through a process to print a page just to avoid 3 pieces of paper running through the printer.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunCommand acCmdPrint
This command will not allow for margin adjustment in Access 2013. It will allow print range though, but the user would need to know to only print page 1.

I can't avoid the error message when setting margins, but they are already set and should remain fine unless I re-size the calendar again. The user will not need to use print preview so I will look into a way to disable the feature to avoid error messages.

I will continue looking around for printing code so only page 1 will print. Maybe this info is out there somewhere.

For now I will just deal with the extra 3 pages when printing.

Thank you all for the help and for your time.
Dec 10 '13 #10

RockKandee
P: 89
Solution

Although my original goal was to eliminate the error message, my ultimate goal was to print the calendar month displayed without any error occurring for the user.

The error message occurs when selecting print preview. Clicking ok on the error box will make the error message go away and print preview (with the data) will display. So setting margins at this time isn't a problem.

Closing the print preview will result in the error message pop up again and clicking ok in the error box will result in closing the view and returning to the calendar form.

Originally, the error would continue to occur when opening tables. Closing and re-opening the database fixed this. This no longer happens for me and I have no idea why.

Once margins are set, to avoid this error message, do not use print preview.

Providing a print button for the user will discourage use of print preview.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.PrintOut Application.Printers("HP Deskjet 3050A J611 series (Copy 1)").Orientation = acPRORLandscape
Using this code worked. No errors. However, this prints all pages. There are 4 pages total. Page 1 is the calendar. Page 2 includes the controls next to the calendar such as the print command button. I re-sized the calendar to make it as larger as possible to fit on one page and still fit on the computer screen. Changing the settings for the print button to be visible on screen only, makes page 2 blank for printing. I am assuming page 3 and 4 are due to the bottom of the calendar form exceeding page 1 and 2 a little bit. These pages are blank also.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunCommand acCmdPrint
Using this code will allow for selecting which pages to print. If the user knows to set the print range to 1 page.

I wanted an explanation free, think free, error free alternative.

Expand|Select|Wrap|Line Numbers
  1. Forms("CalendarAll").Printer.Orientation = acPRORLandscape
  2. DoCmd.PrintOut , 1, 1, acLow, 1, False
Using this code with the print button On Click will result in printing only the first page of the form.

So this is the winner!

Thank you for the time and help.
Dec 10 '13 #11

Post your reply

Sign in to post your reply or Sign up for a free account.