Print report with one click (long) (1 Viewer)

Rowena

Registered User.
Local time
Today, 11:04
Joined
Jul 16, 2002
Messages
27
Greetings,

I have searched the forums, and can't seem to find the solution to my problem.

I have a form for each customer, and a subform for jobs done for them. Each customer can have an unlimited number of individual jobs. I have designed a report which prints a job sheet for the customer, showing the relevant address info and such, which also prints the jobs sorted so the most recent job is printed at the top of the report.

Currently, I have a button that opens the jobsheet query, and another button to print the jobsheet report. To print the job sheet, a user has to run the query, go into design view, put in the customer's first and last names, save the changes, then print the job sheet report.

This is a tiny bit too cumbersome for folks to put up with for long. What I would like to do is have a button to press that would print the current customer record with all the relevant job records.
I have tried putting in some of the code that folks have recommended to others asking similar questions to mine, and I get syntax errors that I don't know how to fix. Currently my non-working button code is:

Private Sub Command79_Click()
DoCmd.OpenReport"[JObSheetReport]",,,"[CUSTID]="&Me.CUSTID"
End Sub

where CUSTID is the numeric primary key for the customer. (Yes, the report name is really spelled like that... :-| )

I have very little experience with Visual Basic, and would appreciate any light you knowledgeable folks can shed on this matter!
Thanks in advance,
Rowena
:confused:
 

Carolyn

Registered User.
Local time
Today, 13:04
Joined
Jun 14, 2002
Messages
28
Hi Rowena,

Have you tried a macro? I like yourself do not have a lot of VB knowledge and I have been able to accomplish many tasks by using macros. Your command button could run the macro which would open your query and report. You might give that a try.

Carolyn
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 14:04
Joined
Feb 19, 2002
Messages
43,453
DoCmd.OpenReport "[JObSheetReport]",,,"[CUSTID] = " & Me.CUSTID
 

Rowena

Registered User.
Local time
Today, 11:04
Joined
Jul 16, 2002
Messages
27
:(

Arrgh!! I amended the code, and now it's giving me Runtime error '2103' and tells me [JObSheetReport] "is either misspelled or doesn't exist"
Here is the amended code:

Private Sub Command79_Click()
DoCmd.OpenReport "[JObSheetReport]", , , "[CUSTID]=" & Me.CUSTID

End Sub

I checked the spelling, and it matches what I have, and it most assuredly DOES exist... I even tried to retype it with a zero instead of an o (in case I had a typo), and I got the same error.

Any ideas? Is there some way to see what the real name is?

Thanks again,
Rowena
 

Rowena

Registered User.
Local time
Today, 11:04
Joined
Jul 16, 2002
Messages
27
Carolyn,

I tried writing a macro, and it worked!! :D

Thanks very much!

Rowena
 
Last edited:

Users who are viewing this thread

Top Bottom