Results 1 to 3 of 3
  1. #1
    babui386 is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Feb 2013
    Posts
    2

    Opening Report using WHERE CLAUSE not working

    Hi

    I am trying to pass value from a button to my report using Table Culum called
    FormID = 1 or 2 or 3.

    In the Report I used Recorsource SQL as below -

    SELECT tblHelp.FormID, tblHelp.HelpID, tblHelp.HelpCategory,
    tblHelp.HelpFormPageName, tblHelp.HelpQuestion, tblHelp.HelpAnswer,


    tblHelp.HelpImageLink
    FROM tblHelp
    WHERE
    (((tblHelp.[FormID])=[Forms]![rptHelp]![FormID]));

    When I open the report directly, it ask for Parameter value and if I enter
    value = 1 or 2 or 3 (FormID), it shows all FormID which has value=1, which I was
    expecting.

    In my form, I used a button which contains below vba -

    Private Sub lblhelp_Click()

    formnum = 1
    ' change the 1 above
    to the correct FormID value

    DoCmd.OpenForm "rptHelp", , , "FormID="
    & formnum
    End Sub

    I am getting below ERROR -

    The form name 'rptHelp' is misspelled or refers to a form that doesnt
    exist

    And in DEBUG highlight -

    DoCmd.OpenForm "rptHelp", , , "FormID=" & formnum


    Could you please help to work it around?

    Regards

    Babui386

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    You said report, so try

    DoCmd.OpenReport "rptHelp", acViewPreview, , "FormID=" & formnum
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    You want to open a form filtered to a single ID value?

    VBA is not finding a form named rptHelp. Are you sure spelling is correct? Or do you really want to open a report?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. docmd.open report 'where' clause
    By khumbo in forum Reports
    Replies: 4
    Last Post: 02-19-2013, 01:14 PM
  2. TOP clause not working
    By fabilewk in forum Queries
    Replies: 5
    Last Post: 08-02-2011, 12:19 PM
  3. Link Criteria no working when opening new form
    By ETCallHome in forum Forms
    Replies: 1
    Last Post: 06-17-2011, 05:26 AM
  4. Report "WHERE" clause not working
    By rsearing in forum Reports
    Replies: 4
    Last Post: 05-26-2009, 02:07 PM
  5. Replies: 1
    Last Post: 07-17-2006, 06:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums