printing same report from different forms

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

Guest

Users can print the same reports from different screen forms, the command
button associated with the printing uses VBA, no problem here.

The problem is that when I have to edit/modify the coding for the printing
comand button I have to do it on each form. Since I have five differnt forms
I have to do the same thing five times!

Is there a way for the buttons to "share" the same coding? that way I'll
have to edit the coding only once. I think it may be done using a module but
not sure about how to do it.

Thank you for your help.

joel
 
I'm not sure I understand. You have five different forms, but they all
launch the same report? Is there a way you could use a single form? That
way, you'd only have a single <Launch Report> button...

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Jeff:

I work for a school. One screen is to add a student to the database - print
personal data.
Another screen is to edit existing student data - print personal data.
Another 2 screens are to find records (my users do commit a lot of typing
errors)
Once the record is found - Print personal data.
Another screen: once the student has enrolled - print personal data.

The personal data report is the same but it has to be printed from different
screens depending on what the user is typing/doing.
 
You might want to take a look at toggling between "Add" and "Edit" mode,
using a single screen. It sounds like all your screens (forms) point at
student data. I suspect you could get by with fewer forms, or even just
with one.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
If your codes are truly the same, then you can write a function and place it
in a module:

Public function openreport()
'Your Code
End function

Keep in Mind:
1. If you are passing a filter or parameter to report, then you will have
to pass it to the function as well.

General Idea:

Public Function openreport(Dim Filter As String)

DoCmd.OpenReport "yourReportName", acViewPreview, , Filter

End Function


The code you would in your command button
Sub on Click

openreport()

end Sub
 
Jeff,
I have to deal with the screens I have, I have no options (based on my
users, sniff...)

Thank you, Dan. That's what I was looking for.
 

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

Back
Top