Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP with Printing!!!! 1

Status
Not open for further replies.

RichardPrewitt

IS-IT--Management
Apr 16, 2002
57
0
0
US
I am working on a program that uses an Access database and I want to create a report that the VB program prints. I do not want to use Word or Crystal Reports. I am trying to create a sub procedure so I can code the reports like:

Printer.Print Tab(40); Format(variable, variable)

something like that but when go to Tools / Add Procedure from the VB main menu, I do not get an option to create a new sub procudure. Is there something else that I need to add to my program to get it produce a report or maybe some help or example in code.

I will also need some examples for code so I can sort by field names in Access.

If I can just use a report from Access that would be even better, but I am fairly new a programming and do not know how to call a report from Access.

I would appreciate any help that you could give me.

Thanks
 
To print an Access report from VB see thread709-744184.

zemp
 
You are awesome! I have been looking for this code for two days now, it's not in any of my six VB books even the VB using Access book that I have. THANK YOU

Not to be a greedy or anything, but . . . .

Do you happen to have some error trapping code just in case the printer isnt on or they didnt connect to the network right. This is the first program that I have worked on that is required to produce reports (5 of the dang things).

I would greatly appreciate it.
 
A standard error handler should do. You just need to determine the erros and act accordingly. See the following faq's for more information.

faq222-1694
faq222-4063



zemp
 
Another thing, sorry for bugging you so much, in your first thread listing in this thread you said change the acViewNormal option to one that allows a preview and someone mentioned changing itto acViewPreview. I tried that with acViewNormal and it printed perfectly, but when I tried it using acViewPreview, it just keep acting like it was thinking and never printed or produced a preview. Am I correct is saying that the code should be same as in the thread except to change the acViewNormal to acViewPreview?

Thanks
 
That all you should have to do. I have not had any problems with it ... yet.

I would try to run the code in Access to see if there is a problem there.

zemp
 
it may have something to do with the fact that I converted the database to '97. I got my copy of Visual Studio 6.0 Enterprise back in '01 and I do not know how to access a database newer than '97. We use everytype of Access here from '97 pro to XP pro to 2003 pro. I am using 2000 pro right now and converting it to '97.

Hm ran into another quick problem. I am trying to force a page break and it isnt cooperating ;)

This is what I am wanting

Header1
header2
fields from database
(continue fields until sort is done)
Page break

repeat till end of records

My problem is in the properties options in the header and body it gives the option to page break after or before but it isnt what I listed above.

Thanks again
 
OK Zemp nm, I figured it out !

Talk about spending too much time on this project, I am starting to dream, sleep, eat and breathe code. If you want a page break like I mentioned in the above post then put the force page break BEFORE the group header.

ya defiently a temporary brain shutdown.

Thanks again for all of your help, it is greatly appreciated.

- Richard
 
Hey Zemp i just found a problem. With the print function. I am using a '97 format Access db and people are going to be accessing it through the VB program with any version of Office on it ranging from '97 to 2003. I myself am using 2000 and I recieve an error every time that I try to print until I open the db, close it and then use the vb program to print from

Any ideas?
 
It might have something to do with the VB IDE or access. I am getting a similar problem with one program. Works the first time and fails after that from the IDE. Open and close VB and it works the first time and fails after that. Run the exe outside of VB IDE and no problems what so ever. Other programs with the same code no problems in or out of the IDE. Has got me stumped. Welcome to the wonderful world of windows! (Sorry, I had to vent)

I would think that version issues with your Access DB are a factor. Especially 97. Might be easier for your clients to upgrade their Office. You would havee to ask an Access expert of which I am not, sorry.

zemp
 
Thank you Zemp,

I am going to buy a newer version of VB. I have VB 6.0 98 enterprise version and only includes addins for office '97

So my boss is buying a newer version.

My plan is to hope that the vb program will work in the newer vb studio. And then to upgrade the Office to XP or 2003 and we are going to upgrade or downgrade their office programs accordingly.

Man! I love to program, but these time crunches and last minute major project changes from the big wig users have got me to question the fun involved with this anymore.

JK I still do massive projects at home but the difference is that I am the user and noone else telling me when it has to be done.

Thanks for your help again.

Oh and I added the errortrapping to my printer function and it works fine now except for your above mentioned problem lol. But at least it doesnt crash when the report doesnt print.

Thanks a million squared

- Richard
 
VB itself has not changed in a while. Just make sure that you have the latest service pack (SP6).

zemp
 
ok thanks, the version I have is one that I got while in college back in 2000 and they supplied us with the school's older copies of '98 when they bought their new realses.

- Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top