Results 1 to 5 of 5
  1. #1
    khumbo is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Posts
    12

    docmd.open report 'where' clause

    hey guys, i've been working on this bit of code all day! Im trying to take the ID from a selected item on a listbox and use it to open a report where the ID equals the ID in the table. I hope that makes sense. Anyway here is the code:



    Dim varItem as Variant
    Dim currentRow as Integer

    For currentRow = 0 to Me.ListJobcards.ListCount - 1
    If Me.ListJobcards.Selected(currentRow) Then
    varItem = Me.ListJobcards.ItemData(currentRow)
    End If
    Next currentRow

    DoCmd.OpenReport "cash sale", acViewReport, ,"Jobcard.[ID] = " & varItem

    When i call the method i get an inputbox telling me to enter 'Jobcard.ID'. Im assuming it has something to do with the formatting of the where statement. Please help. Much appreciated.

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    The parameter prompt is Access telling you it can't find something. Try:

    DoCmd.OpenReport "cash sale", acViewReport, ,"[ID] = " & varItem

    And make sure ID is a field in the report's source.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    khumbo is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Posts
    12
    thanks for the quick response. I get the same inputbox but instead of jobcard.ID it just writes ID. Not sure what i'm doing wrong.

  4. #4
    khumbo is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Posts
    12
    Nevermind, i checked for the ID in the report source and it wasnt there. Once i got that done, worked like a charm. Thanks so much.

  5. #5
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    No problem.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 5
    Last Post: 11-07-2012, 08:15 AM
  2. DoCmd WHERE Clause not filtering form
    By tylerg11 in forum Forms
    Replies: 3
    Last Post: 02-29-2012, 01:09 PM
  3. Help on where clause of open form
    By Madmax in forum Access
    Replies: 5
    Last Post: 06-23-2011, 11:19 AM
  4. Select / DoCmd to open another form
    By chrisjack001 in forum Access
    Replies: 1
    Last Post: 08-24-2010, 12:31 PM
  5. Replies: 1
    Last Post: 07-17-2006, 06:30 AM

Tags for this Thread

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