Thread: Creating a form letter
06-27-12, 23:04 #1Registered User
- Join Date
- Jun 2012
Unanswered: Creating a form letter
I've been working on this a while and I found that in order for a button on a form to open a report and for all the fields on the form to appear in the report, the record source of both the form and the report have to be the same. Doing this from my test db, I based my form and report on a query of several tables and was able to click the button to open the report. Everything worked great.
On my live db, however, there are 900+ records. The form I'm using to view the records (frmPrchsReview) is based on the db's main table (tblPurchases). The tab page with the command button is part of the frmPrchsReview form. On this tab page, there are also radio buttons which let the reviewer choose which category the purchase falls into. When the command button is clicked, a new form pops with a basic outline of the letter. The new form (frmRvwLetter) needs to include the PurchaseID from the frmPrchsReview form's current record, the PurchaseName from frmPrchsReview form's current record and a paragraph from a different table, tblLetterContent, that corresponds to the radio button category chosen. The new form, frmRvwLetter, needs to open because it contains a textbox where the manager enters a sentence or two which must appear on the letter, rptLetter. Once the text is entered, another command button on frmRvwLetter is clicked to open rptLetter.
In my vast experience with Access (since March) which made me believe I had to base a form and the report which comes from the form on the same record source, it seems I need to do this with the command buttons:
Command button 1 on frmPrchsReview (Tab 3):
From frmPuchsReview, get the PurchaseID and PurchaseName from the current record; then, get the paragraph from tblLetterContent that matches the radio button chosen on the tab page, and put them on frmRvwLetter.
Command button 2 on frmRvwLetter:
Then, get the PurchaseID, PurchaseName, paragraph text and the sentence entered by the manager and put it on rptLetter.
Am I way off? How do I do it?
06-28-12, 11:35 #2Moderator
Provided Answers: 14
- Join Date
- Mar 2009
When you issue a DoCmd.OpenReport command to open a Report, there are additional parameters that you can include in the instruction and that are used to filter the data from the Report RecordSource (Table or Query):
DoCmd.OpenReport(ReportName, View, FilterName, WhereCondition, WindowMode, OpenArgs)Have a nice day!
06-28-12, 13:50 #3Moderator
Provided Answers: 19Hope this helps!
- Join Date
- Jun 2005
- Richmond, Virginia USA
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007