Results 1 to 9 of 9
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Pop Up DIalogue forms (2003)

    I have created a pop up dialogue form (I think) to capture a value which is used as a criterion in a query which underlies a report.
    The form has Popup and Modal set to Yes; Border is set to Dialogue.
    There is a macro RunWinners which comprises the command OpenForm, which opens the modal form
    The report has a call to the macro in its On Open event.
    The system is not working because, although the form pops up, the report/query has already run and produced incorrect results.
    What do I need to do to get the form to pop up so I can capture the value which is then used by the query on which the report is based, please?
    Thanks
    Silverback
    Silverback

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Pop Up DIalogue forms (2003)

    Instead of opening the form from the On Open event of the report, open the report in the On Click event of a command button on the form.

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Pop Up DIalogue forms (2003)

    Thanks - it's working fine, now. But two supplementary questions, please.
    1. If I open the report using the AcViewPreview parameter, nothing happens i.e. something appears to go on but the report doesn't appear on the screen and the form doesn't close. Using acViewNormal as the parameter i.e. put the report straight into printing mode works fine. What's happening when I use the acViewPreview option?
    2. Is there a way to organise things so the report 'starts', then the dialogue form opens, then the query runs and the report opens? (just for curiousity)
    Thanks
    Silverback
    Silverback

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Pop Up DIalogue forms (2003)

    1) The popup form will stay on top of the report (that's the definition of popup), so if the form is larger than the report, the report window will be covered by the form window.

    2) I don't really know, but I don't think so.

  5. #5
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Pop Up DIalogue forms (2003)

    Hans
    I have implemented your suggestion that clicking a command button on a modal form results in a report being opened. This works – after a fashion.

    If I use the acViewNormal option in the DoCmd.OpenReport “ReportName”, acViewNormal statement, all works OK. It does, however, result in a file being queued for printing, so I have to keep print preview switched on so I can cancel the report while testing. This doesn’t seem right, so I tried to use the preview option.

    If I use the acViewPreview option (which is the option VBA prompts me with) then I get nothing. When I click the command button, all that happens is that the Access control dialogue (the one which lists Tables, Queries, Forms etc) ‘blinks’. The form does not close and no report is visible. The form close is part of my VBA routine, so it’s almost as if control is not being passed back to the routine after the report call. (After trying many, many times, my eyes focused enough to determine that this ‘blinking’ appears to be a report preview window being opened then closed immediately.)

    In desperation, I added another command button, using the control wizard, and selected the “preview a report” action in the wizard. If I run the form, then click this new button, the report previews OK.!

    I noticed then that the parameter generated by the control wizard was acPreview – not acViewPreview – so I changed the OpenReport line in my VBA routine to use acPreview.
    Same result as before – the report did not open.

    Finally, I copied the VBA OpenReport lines of code from the newly added command button routine and pasted that into my VBA routine, commenting out my original OpenReport line.
    Same result as before – no report.

    One last thing. If I use the new “Preview Report” button, the report appears in Report Preview window. If I leave this on view, and click my original command button, the window/report disappears.

    I have tried unsetting modal, popup and border for the form with no alteration in effect. The form is not bigger than the report.

    Has you any idea(s) what might be needed to get report preview working, please?
    Thanks
    Silverback
    Silverback

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Pop Up DIalogue forms (2003)

    It won't make any difference whether you use acPreview or acViewPreview - they have exactly the same value 2.

    Could you post a stripped down copy of your database? See <post#=401925>post 401925</post#> for instructions. We'd only need the form and report, plus the table(s) behind the report with just a single record or so.

  7. #7
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Pop Up DIalogue forms (2003)

    Hans
    Thanks for this. Stripped down DB attached.
    Open Form WinRepModal.
    Select first option - All Winners and Prizes for a Single Draw Value; input fields will appear.
    Use values Year = 1, Draw Number = 4
    Click Produce Report. This will produce the 'blinking' effect for as many times as you click the button.
    Click Preview Report and the report will appear.
    Use Exit Form button to get back to Access control.
    Thanks
    Silverback
    Attached Files Attached Files
    Silverback

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Pop Up DIalogue forms (2003)

    The On Click event procedure for the "Produce Report" button contains these lines:

    DoCmd.OpenReport stDocName, acPreview

    ' Close the form
    DoCmd.Close

    But the instruction DoCmd.Close doesn't close the form. It closes whichever window has the focus when it is executed, i.e. the report you just opened. Hence the blinking effect.
    You have to tell the instruction explicitly to close the form instead of the report:

    DoCmd.Close acForm, Me.Name

  9. #9
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Pop Up DIalogue forms (2003)

    Hans -Thank you, thank you, thank you.
    Saved me from going <img src=/S/nuts.gif border=0 alt=nuts width=15 height=15>
    Silverback
    <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>
    Silverback

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •