473,398 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

print current report

14
hello educated friends

i have a question. i created a table name info. the primary key field is [maininfoID], i created a query from that table named it [info query], and a form from that query. On my form which by the way named [timesheet]i want my employees to enter data,then press the print button to print out a current report of the information that was just entered. report name is [yourcopy] i was told to use this event procedure
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "rptyourcopy",acViewPreview, , _
  2. "[maininfoID]=Forms!frmtimesheet"
i know theres more to this, can someone help me please.
Dec 29 '11 #1

✓ answered by Stewart Ross

The error message is pointing out the obvious - read your last post. Why have you got this line?

strReport = "info"

Info is NOT the correct name of your report, which you have said yourself is yourcopy. That line should surely be

strReport = "yourcopy"

or, if that too is incorrect and it is really what you posted in post #1,

strReport = "rptyourcopy"

You have to be consistent and correct in what you post!!

-Stewart

3 2167
Stewart Ross
2,545 Expert Mod 2GB
It is essential that you understand what the code is doing - being 'given it' is not enough. The OpenReport action can be filtered so that instead of the report showing all records it shows just a subset of them, or in this case, the record matching the one in your form.

To do this the MainInfoID field on the report has to be matched to the corresponding value on your form - but at present (in line 2 above) you are not supplying the value of the field at all, just a reference to the form itself. You also need to include the value of the control, not a reference to its name, in the filter statement.

Assuming that the control on your form is also called maininfoID, try replacing line 2 with:

Expand|Select|Wrap|Line Numbers
  1. "[maininfoID] = " & Forms!frmtimesheet!maininfoID
or, using the simpler reference to the current form itself available using the Me keyword,

Expand|Select|Wrap|Line Numbers
  1. "[maininfoID] = " & Me!maininfoID
This assumes that your primary key is a number. If it is not a number but is instead a text string, you would need to include the value inside single quotes, like this:

Expand|Select|Wrap|Line Numbers
  1. "[maininfoID] = '" & Me!maininfoID & "'"
Please note that this last example is for text strings only - it will not work at all if the value being matched is a number, so please do not confuse the two forms of the statement!

-Stewart
Dec 29 '11 #2
jawbone
14
ok Mr Ross
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command151_Click()
  2. Dim strReport As String
  3. Dim strWhere As String
  4.  
  5. strReport = "info"
  6. strWhere = "[maininfoID] = """ & Me![maininfoID] & """"
  7.  
  8. DoCmd.OpenReport strReport, acViewPreview, , strWhere
  9.  
  10. End Sub
im getting a run-time error 2103, :the report name you entered incorrect but i know its correct the name is [yourcopy]
Dec 29 '11 #3
Stewart Ross
2,545 Expert Mod 2GB
The error message is pointing out the obvious - read your last post. Why have you got this line?

strReport = "info"

Info is NOT the correct name of your report, which you have said yourself is yourcopy. That line should surely be

strReport = "yourcopy"

or, if that too is incorrect and it is really what you posted in post #1,

strReport = "rptyourcopy"

You have to be consistent and correct in what you post!!

-Stewart
Dec 29 '11 #4

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

Similar topics

1
by: JSB | last post by:
I am new to Access and am hoping an Access guru out there can help me. I am using an Access 2002 project to report on a SQL Server database. I am reporting various information for around 100...
3
by: simonmarkjones | last post by:
Hi i need to be able to print a report to act as a receipt for customers. If i put a button on a form to do this it wont print the current details on a newly created form (Prints Report with no...
1
by: Kadir | last post by:
Hi All, I have a problem in printing reports. I have a dot matrix printer. I want to print a report that varies in height each time according to the details. If I set the page to A4 it goes onto...
3
by: Santosh | last post by:
Hii.. i am printing crystal reports in asp.net for that purpose i am using PrintTo Printer method but for that it is needed me to pass printer name which is installed on my local computer but...
2
by: mark1 | last post by:
Hello to all. I am trying to print a report for an individual record, I have several hundred records but need to print specific reports, is this possible? Mark
4
by: jyothsnasiri | last post by:
Hi, I was able to get the report using crystalreport11 but the problem was unable to print the report in crystalreportviewer. So plz help me if anyone knows the answer. thanku in advance
1
by: G Gerard | last post by:
Hello When I want to print a report using code I normally use the following code DoCmd.OpenReport "RptName", acViewNormal This works OK when I'm only printing one copy of the report. What...
3
by: NMarks | last post by:
Hello, I currently have a continous form that has a search field in the header. The search works without issue, but I want to be able to print a report based off the search results. All the...
12
by: Studiotyphoon | last post by:
Hi, I have report which I need to print 3 times, but would like to have the following headings Customer Copy - Print 1 Accounts Copy - Print 2 File Copy -Print 3 I created a macro to...
2
misscrf
by: misscrf | last post by:
I have a report which is grouped in header and footer. Each report has the page break set on the group footer. Any way I can write code or a macro or something that will print my report to a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.