Results 1 to 5 of 5
  1. #1
    kassem is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    22

    How to modify code to open report instead of form


    Hi guys,

    the following code opens a form to the specific record clicked on the listbox. This works but i want the code to open a report instead. I tried changing OpenForm to OpenReport and FormName to ReportName but it keeps printing the report instead of opening it, thanks.

    Code:
    DoCmd.OpenForm FormName:="Trouble_Report", _
           WhereCondition:="[Device ID]='" & Me.
    [List311] & "'"

  2. #2
    Subwind is offline Can Only Learn
    Windows XP Access 2010 32bit
    Join Date
    May 2012
    Location
    Portsmouth, UK
    Posts
    61
    Quote Originally Posted by kassem View Post
    Hi guys,

    the following code opens a form to the specific record clicked on the listbox. This works but i want the code to open a report instead. I tried changing OpenForm to OpenReport and FormName to ReportName but it keeps printing the report instead of opening it, thanks.

    Code:
    DoCmd.OpenForm FormName:="Trouble_Report", _
           WhereCondition:="[Device ID]='" & Me.
    [List311] & "'"
    DoCmd.OpenReport "Trouble_Report", acViewPreview to preview
    DoCmd.OpenReport "Trouble_Report", acViewPrint to print

  3. #3
    kassem is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    22
    I tried
    Code:
    DoCmd.OpenReport "Trouble_Report", acViewPreview 
           WhereCondition:="[Device ID]='" & Me.
    
    [List311] & "'"
    but its saying the where condition now has incorrect syntax do you know why?

  4. #4
    Subwind is offline Can Only Learn
    Windows XP Access 2010 32bit
    Join Date
    May 2012
    Location
    Portsmouth, UK
    Posts
    61
    Quote Originally Posted by kassem View Post
    I tried
    Code:
    DoCmd.OpenReport "Trouble_Report", acViewPreview 
           WhereCondition:="[Device ID]='" & Me.
    
    [List311] & "'"
    but its saying the where condition now has incorrect syntax do you know why?
    All my reports are based on queries that filter the data for me so I am unable to help on that front.

    ~Matt

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Your syntax of

    "[Device ID]='" & Me.[List311] & "'"

    is only correct if [Device ID] is defined as a Text Field. If it is defined as an actual Number, then correct syntax would be

    "[Device ID]= " & Me.[List311]

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. How to modify report based on input form
    By pmatush in forum Reports
    Replies: 1
    Last Post: 02-22-2013, 09:47 PM
  2. Replies: 1
    Last Post: 05-03-2012, 02:25 PM
  3. Replies: 1
    Last Post: 02-01-2012, 01:27 AM
  4. SQL*Plus code in MsAccess, how to modify?
    By suverman in forum Queries
    Replies: 1
    Last Post: 05-20-2011, 07:01 AM
  5. Word code in Access - How to modify my current code
    By Alexandre Cote in forum Programming
    Replies: 0
    Last Post: 11-15-2010, 08:26 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