Form vs. Report - what am I looking at?

I've created a "parameterForm" to allow me to get input.  So, I open the 
"pForm", get input, then open the query, open the report, close the query, 
close the "pForm".

The screen output looks fine -- the value for the textbox related to the 
parameter query/form is 45; when I print the report, however, it prints an 
"#Error" for the value.

A clue (which I can't decipher) might be the following:  I have a label in 
the report that I "fill" from VBA, based on the value of a textbox in the 
parameterForm; I have no such label on the form; what I see on the screen 
does not "fill" the label, but the printed report has the label caption. 
Maybe I'm not looking at the report on the screen, but at the form (which I 
never opened, but from which I created the report).

Here is my VBA code:
Private Sub cmbOK_Click()
    Dim closeIt As Integer, theTerm As String
    DoCmd.OpenQuery ("yqCUS")
    DoCmd.OpenReport "rStats", acViewPreview
    theTerm = Application.Forms("fgetStats").Controls("tbxBegDate") & " - " 
& Application.Forms("fgetStats").Controls("tbxEndDate")
    Application.Reports("rStats").Controls("labTerm").Caption = theTerm
    DoCmd.Close acQuery, "yqCUS", acSaveNo
    DoCmd.Close acForm, "fGetStats", acSaveNo
    DoCmd.PrintOut acPrintAll
    closeIt = MsgBox("Close report?", vbYesNo, "Close report?")
    If closeIt = 6 Then
        DoCmd.Close acReport, "rStats", acSaveNo
    End If
End Sub

Can somebody help me understand the discrepancy between what I see and what 
I print?  (?)

TIA


0
zSplash
3/29/2007 8:35:02 PM
access.reports 4434 articles. 0 followers. Follow

2 Replies
728 Views

Similar Articles

[PageSpeed] 29

If the report's query is reading the value from the form, you must leave the 
form open until the report is finished with it.

An alternative approach might be to use the WhereCondition of OpenReport, so 
it passes values to the report's Filter instead of having the report's query 
refer to the form.

-- 
Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"zSplash" <zsplash@nospamPlease.com> wrote in message
news:%23wG$kHkcHHA.2268@TK2MSFTNGP02.phx.gbl...
> I've created a "parameterForm" to allow me to get input.  So, I open the 
> "pForm", get input, then open the query, open the report, close the query, 
> close the "pForm".
>
> The screen output looks fine -- the value for the textbox related to the 
> parameter query/form is 45; when I print the report, however, it prints an 
> "#Error" for the value.
>
> A clue (which I can't decipher) might be the following:  I have a label in 
> the report that I "fill" from VBA, based on the value of a textbox in the 
> parameterForm; I have no such label on the form; what I see on the screen 
> does not "fill" the label, but the printed report has the label caption. 
> Maybe I'm not looking at the report on the screen, but at the form (which 
> I never opened, but from which I created the report).
>
> Here is my VBA code:
> Private Sub cmbOK_Click()
>    Dim closeIt As Integer, theTerm As String
>    DoCmd.OpenQuery ("yqCUS")
>    DoCmd.OpenReport "rStats", acViewPreview
>    theTerm = Application.Forms("fgetStats").Controls("tbxBegDate") & " - " 
> & Application.Forms("fgetStats").Controls("tbxEndDate")
>    Application.Reports("rStats").Controls("labTerm").Caption = theTerm
>    DoCmd.Close acQuery, "yqCUS", acSaveNo
>    DoCmd.Close acForm, "fGetStats", acSaveNo
>    DoCmd.PrintOut acPrintAll
>    closeIt = MsgBox("Close report?", vbYesNo, "Close report?")
>    If closeIt = 6 Then
>        DoCmd.Close acReport, "rStats", acSaveNo
>    End If
> End Sub
>
> Can somebody help me understand the discrepancy between what I see and 
> what I print?  (?)
>
> TIA
>
> 

0
Allen
3/30/2007 1:52:31 AM
Perfect!  Moved the print report line to before closing the form, and --  
problem solved!
Thanks, Allen.

"Allen Browne" <AllenBrowne@SeeSig.Invalid> wrote in message 
news:%23B4YW4mcHHA.3644@TK2MSFTNGP02.phx.gbl...
> If the report's query is reading the value from the form, you must leave 
> the form open until the report is finished with it.
>
> An alternative approach might be to use the WhereCondition of OpenReport, 
> so it passes values to the report's Filter instead of having the report's 
> query refer to the form.
>
> -- 
> Allen Browne - Microsoft MVP.  Perth, Western Australia
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "zSplash" <zsplash@nospamPlease.com> wrote in message
> news:%23wG$kHkcHHA.2268@TK2MSFTNGP02.phx.gbl...
>> I've created a "parameterForm" to allow me to get input.  So, I open the 
>> "pForm", get input, then open the query, open the report, close the 
>> query, close the "pForm".
>>
>> The screen output looks fine -- the value for the textbox related to the 
>> parameter query/form is 45; when I print the report, however, it prints 
>> an "#Error" for the value.
>>
>> A clue (which I can't decipher) might be the following:  I have a label 
>> in the report that I "fill" from VBA, based on the value of a textbox in 
>> the parameterForm; I have no such label on the form; what I see on the 
>> screen does not "fill" the label, but the printed report has the label 
>> caption. Maybe I'm not looking at the report on the screen, but at the 
>> form (which I never opened, but from which I created the report).
>>
>> Here is my VBA code:
>> Private Sub cmbOK_Click()
>>    Dim closeIt As Integer, theTerm As String
>>    DoCmd.OpenQuery ("yqCUS")
>>    DoCmd.OpenReport "rStats", acViewPreview
>>    theTerm = Application.Forms("fgetStats").Controls("tbxBegDate") & " - 
>> " & Application.Forms("fgetStats").Controls("tbxEndDate")
>>    Application.Reports("rStats").Controls("labTerm").Caption = theTerm
>>    DoCmd.Close acQuery, "yqCUS", acSaveNo
>>    DoCmd.Close acForm, "fGetStats", acSaveNo
>>    DoCmd.PrintOut acPrintAll
>>    closeIt = MsgBox("Close report?", vbYesNo, "Close report?")
>>    If closeIt = 6 Then
>>        DoCmd.Close acReport, "rStats", acSaveNo
>>    End If
>> End Sub
>>
>> Can somebody help me understand the discrepancy between what I see and 
>> what I print?  (?)
>>
>> TIA
>>
>>
> 


0
zSplash
3/30/2007 4:52:21 PM
Reply:

Similar Artilces:

Reservation Form
I have an active website for my business. I built it in Frontpage 2002. It no longer will send email through the settings I used ( Reservation form) and I cannot get it to take any of the settings I give it. I do not think that my knowledge is sufisticated enough. And, I don't think that I am entering the information completely enough. I am using a simple form with a single enter button. Can you help? May be possible. -- ~~~~~~~~~~~~~~~~~~ Rob Giordano Microsoft MVP Expression Web "FrontPage 2002 on windows XP" <FrontPage200...

Auto populate a form form an open form
Hi I have a main form with customer names and addresses and would like to add a control button on this form which opens up another form which is used for recording telephone calls on. What I have been trying to do is auto populate this call log form with information from the main form ie name and address? Any thoughts Thanks Chris Chris, Please don't re-post the same question twice. You have to be patient and wait for a reply. Responders are volunteers, and you may not get an answer right away. Posting twice causes some people to respond to the first post, while others are ...

form pozition on screen
I would like to find form position on screen. It's similar to DoCmd.movesize, but I want discover "parameters' for form position (left corner, top corner, etc) Are you saying that you want to find out what the current position IS? If so, you can use something like this: MyFormLeftVariable = Me.Left MyFormTopVariable = Me.Top MsgBox "My Form is at " & MyFormLeftVariable & VbCrLf & MyFormTopVariable Or however you want to use it. -- Bob Larson Access World Forums Super Moderator Utter Access VIP Tutorials at http://www.btabdevelopment.com ___________...

copy properties Under forms
Hi, I'm wondering if someone can help me with something on copying properties. I've checked the access help but can't find anything there. This is what i want to do. I'm copying text boxes, labels that has caption, name and other information in the properties that i want to keep when i copy the information to another tab on a form. Is there a way i can copy the property information without doing alot of manual work by going into each text or label box. I hope this makes sense. thanks for you help in advance. Keith When you copy a control, everything about the cop...

What is the purpose of 'Dummy' window in the Command forms
I am wondering why GP has Dummy window with title "~internal~" for the Command forms. For example Command_Financial form has Dummy window Do I need to create Dummy window for my Command forms. If so why I need it. Any comments appreciated!!! Hi Mandeep, The Dummy window is there as a placeholder. It really doesn't do anything, but should be there in order for the form to work properly since your form needs to be open for the commands to be available. The title ~internal~ just prevents this window from showing up in the Security assignment windows. Make sure that...

Report broken down by results from a calculated field
Hello, I have a query which calculates a date which is 100 days from the initial referral date. Other fields in the query are: patient ID, date of surgery and the reason why no surgery within 100 days of referral if applicable (this field is added through a combobox that only gives choice of 3 options). I would need a report that groups the results of the calculated field (those who had surgery within 100 days of initial referral, those who did not have surgery within 100 days and those who do not yet have surgery date. Those who do NOT have surgery within 100 days of referral, I nee...

Cannot open the Insert object (Pdf file) form Excel 2000(9.0.8968 SP-3)
Dear All, I am no idea why I cannot open the embedded object (Pdf file) inside Excel file which using Windows ME. Once clicked the object icons, then it shows the error message likes " the embedded object cannot be opened by the source application" I used the Adobe reader 6.01 as the source application. Actually, I searched the related forum from the Internet. However, I cannot solve the problem. Anyone helps? Thanks tlee Hi, I can't test 2000 in ME, but it works fine in 2003 under XP. -- If this helps, please click the Yes button. Cheers, Shane Devenshire &q...

Form class module for non-existent form
Hi, After copying a form with a class module, something went wrong. I now have a class module for the new form, but the form no longer exists. I am unable to remove the in-limbo class module. I want to use that name for my form, which is not possible as long as that class module is in the way. How do I get rid of the in-limbo class module? I've tried repairing tha DB as well as "msaccess /decompile" but it hasn't helped. Anything else? Thanks, Kjell Kjell, A class module is not part of a form, but a separate module. It sounds like your 'in-limbo' module is...

actual vs plan chart
I have a table of data, let's call it ACTUAL SALES by month, similar to following: Business Unit West East North South Jan09 20 30 15 10 Feb09 10 20 30 40 Mar09 14 16 12 10 I have a table that looks like it, for PLANNED SALES data, with various numbers for each business unit's planned target for the same periods for which I have actuals. What I want to do is (ideally) create a stacked bar chart of the Actuals for each region (ie, the height of the stack = total actual sales), ...

Look up problem
Part 1 I have this look up in cell H18. =LOOKUP(RIGHT(I18,2),$G$68:$H$75) Cell I18 is formated as text but contains numbers like 123405. The RIGHT(I18,2) takes the last 2 digits (the 05) and does the lookup. This works except when a number that is not in the lookup range is entered in I18. For example, if 95 is entered the lookup returns the lookup for 05. My first question is how can I return only valid input in the LU range. Part2 If nothing is in Cell I18 then #N/A appears in H18. The #N/A looks awful. The second question is how can I show nothing in H18 when I18 is blank. I have Exc...

Setting the Windows Cursor during Form Processing
hiya gurus I would like to force the mouse cursor to immediately become an hourglass when some long processing/quering commences on a form. it appears that it takes some time for Access to show the hourglass and usually only after the user clicks the form a couple of times because there appears to be nothing happening... Is there an easy way to do this from within Access.. I have done it in VB6 using Me.MousePointer = vbHourglass but this does nto work in Access.. any suggestions? cheers Jeff mmmmm Screen.MousePointer = 11 guess this does it? "jeff" <jeff@work...

Position 2nd Form according to 1st Form
I have 2 Forms. When the 1st Form is openned and want I open the 2nd Form, I want it to position itself about 15cm form the Left and 20cm from the top of the 1st Form. I am using Access 2003, Thanks. "AY" <AY@discussions.microsoft.com> wrote in message news:CFA3A4B5-36D9-4A20-AB57-601290155335@microsoft.com... >I have 2 Forms. When the 1st Form is openned and want I open the 2nd Form, >I > want it to position itself about 15cm form the Left and 20cm from the top > of > the 1st Form. I am using Access 2003, Thanks. You should be able to use Nicole Calinoiu...

TOURNAMENT FORMS
Need tournament draw sheet single elimination template. You may find some old NCAA basketball tournament forms out on the web. Try http://google.com HHSTENNIS wrote: > > Need tournament draw sheet single elimination template. -- Dave Peterson ec35720@msn.com ...

Run Macro only if certain form is open
I have programed a maco to open one of various forms depending on criteria on an open form. Is there a way to run a "follow up Macro" based on which form opens? In other words can I run a macro based on wheather a certain form is active? -- Thanks, Chuck Take a look at the RunMacro Method of the DoCmd object. You can have it as part of the OnLoad of the form in question. Chuck wrote: >I have programed a maco to open one of various forms depending on criteria on >an open form. Is there a way to run a "follow up Macro" based on which form >opens? In other w...

Forms and Input Data
I created a report form on Sheet 1 and a set of input data on subsequen Sheets 2, 3, ... link to the report. The report is to show informatio on either of the data I select. Are there simple steps for me to pick either set of data I want t display on the report? I've thought of a pull-down menu so that if select "1", the report will show data set "1", and so on. Yet I don' know how to do it. I tried the "replace" command by highlighting al the cell in the Report sheet then type "2" in place of "1" to replac the data set then hitting...

Modal form opens on startup
Evenin' - I hope this doesn't come across as stupid, but I'm almost completely unfamiliar with Access. A client of mine has an Access 2000 database containing some business information, and he'd like to have me import it into Quickbooks. The problem I have is that I cannot get to the information to export it from Access. When the file is opened, I get a (I presume) modal form, configured as a 'splash screen' type of thing. Has my client's logo, and the name of the fellow who wrote the Access app. Click that, and it closes, then opens another form for...

Trying to delete form border, and it deletes all borders
I made a form with several individual areas that have borders. At the end I decided to try a border around the whole form. Now that I don't like it, I was trying to delete the form border, but it deletes all the borders in the form as well. How can I just delete the border around the form and not the rest of the individual borders? I'm actually on a different computer, because of the printing, will I be able to undo my way out of it maybe, or do I have to be on the computer where I made the form. One more question, will the form retain the undo feature for ever, or will it stop ...

how to solve "Non-modal forms cannot be displayed in this host application"
Hi, I am trying to make a modalless form in VB6 that is compiled as an ActiveX DLL. When i use VC6 to instance the activex DLL, my problem appears that "406 Non-modal forms cannot be displayed in this host application from an ActiveX DLL, ActiveX control or Property Page." I have my form in modalless style in VB6 and they should be instanced in VC. Does anyone know how to get this to work ? Many Thanks, Xiao http://support.microsoft.com/default.aspx?kbid=176468 -- Regards, Nish [VC++ MVP] http://www.voidnish.com http://blog.voidnish.com "arbidol" <arbidol@tom...

Protecting a section of a report
I would liek to know how to protect a certain part of a report doc, I am on Vista using student 2007 microsoft office. I have tried the way it says to do for word, but when I tick the drop down box for filling in forms the part underneath disappears (Exeptions)...any ideas? -- Regards, Patteam The Exceptions feature and Forms protection cannot be used at the same time. The typical approach is to create a template and protect it for forms. That template is then used to create documents wherein the only input allowed is in the forms items. If you need to modify the underlying d...

Temporary Form with 2 Sub form Update Main Form And its Sub form ?
I have 2 table both are exactly same PatientRecordTransTb And PatientRecordTb I know many programmer don’t like TempTb, but in my case I don’t trust some one to mess with my Main record table. So simple solution is make tamp table and after review I click to transfer all records from temp Table to main Table So I have two forms . PatientRecTransFm record sources = PatientRecordTransTb PatientRecordMainFm record source = PatientRecordTb PatientRecTransFm has 2 button AddRecord And Delete Record Here is a short story of my code (NOT A Actual Code) mySQLString = &quo...

Z report total
How do I print a total z report that has all the batches for one day? -- Thank you Terry Terry, This is not functionality that is present out of the box. We have created a customized solution called the consolidated Z report. If you are interested in learning more, please give me a call or drop me an email. -- Thank you, Ryan Sakry Program Manager Retail Information Technology Enterprises 320-230-2288 rsakry@rite.us www.rite.us "Terry" <Terry@discussions.microsoft.com> wrote in message news:CB404C7B-4AD2-4466-86E7-168CC27A791C@microsoft.com... > How do I print a t...

I need book lending forms
Please I need your help, I'm looking for book lending forms in order to keep control of which books I'm borrowing and when they have to be returned to me. Thanks ...

Previewing a report
I am trying, with a commnd button in DB1, to preview a report from a DB2. I did the following: I created in DB2 (the one with the report) a Macro - Echo, set warnings, Open report (in preview), Quit I use the following code for my command button in DB1: ****************************************** Private Sub preview_Click() Call Shell("""C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE"" ""C:\cps208\sales.mdb""/Xpreviewcommission ", 0) End Sub ****************************************** I did the same to print the the report and its wo...

Customization to a Contact Form Does NOT Stick
Everytime I try to add a field in a Contact form, the change does not stick. I have administrator rights, followed the instructions to customize a form to the t. The instructions entailed going to: Home -> Settings Settings tab -> System Customization Record Management -> Contacts Add Fields -select fields to add ok - > save work On the CRM server Start -> Programs -> Microsoft CRM -> Deployment Manager Right click: Deployment Manager -> All Tasks ->Publish Customization Select form customized Add Finish OK Restart IIS After performing these steps, I get b...

Make Access report for bills
Hello, This is the first time that I am designing a report in access. The report for the bill works fine but is there a way to "add" a custom page layout/design/content to the report (for information-text about the bill) If it is possible it would need to be recognized by the report as a page because I have on every page the page num/num. Thank you in advance. juvi You should be able to create a separate report that has just the information stuff on it. Then, add this as a subreport in the Report footer. If you click on the report footer bar, it should give you an option t...