Results 1 to 10 of 10
  1. #1
    bryanCalabro is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2015
    Posts
    6

    Generating Report Based off input from a form


    I have three tables that keep track of the projects going on for my local municipality. The tables are project, orders, and change orders. I am in the midst of creating a user interface based solely off of forms and navigation buttons. On one of those forms I want the user to be able to input the projectId and it print a report of all of the orders that correspond with this projectId. I am taking the input from the form and running through a VBA Statement like this... DoCmd.RunSQL ("SELECT * FROM Project WHERE Project.projectID = " & me.inputId), which is giving me the information I want, but now I just need to put that into a report. Any suggestions?

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    DoCmd.OpenReport supports a "Where Condition" argument.

  3. #3
    bryanCalabro is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2015
    Posts
    6
    Thanks RuralGuy, i have been playing around with that. However I am trying to make the report based off of the form input. For example, if the user inputs into three text fields, projectID, start date, and end date, then i want to generate a report with all of the orders for that project id within the given time slot. In the where condition im trying
    "Order.projectId = " & me.inputId & " AND Order.startDate > " & me.startDate & " AND Order.endDate < " me.endDate

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Parameters for text fields need apostrophe delimiters, date fields need # delimiters, number type do not need delimiters. Probably don't need the Order. prefix. Missing an & for concatenation.

    "projectId = " & me.inputId & " AND startDate > #" & me.startDate & "# AND endDate < #" & me.endDate & "#"

    If you want the date range to be inclusive, use >= and <= operators.

    This requires input into all 3 textboxes.
    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.

  5. #5
    bryanCalabro is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2015
    Posts
    6
    I'm trying it and it's still not working, I am now trying with just "projectId = " & me.inputId but its printing out the entire report with all records. Here is the exact code DoCmd.OpenReport "OrderReport", acViewReport, "[projectId] = " & Me.id

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    If you want to provide db for analysis, follow instructions at bottom of my post.

    Should that code be Me.id or Me.inputId? Are these UNBOUND textboxes for input of filter parameters? What is name of textbox?
    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.

  7. #7
    bryanCalabro is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2015
    Posts
    6
    This is my DB. I'm making it for old people who want a user interface inside the program, which is what the navigation form is for. And i double checked all of the names, they line up, and the text field is unbound.
    Attached Files Attached Files

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    The criteria is in the wrong argument. Missing a comma.

    DoCmd.OpenReport "OrderReport", acViewReport, , "[townshipProjectId] = " & Me.id
    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.

  9. #9
    bryanCalabro is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2015
    Posts
    6
    Thank you June7! That did the trick. This is my first time using access so do you have any other pointers for me based off what you saw?

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Might want to remove spaces from object names.
    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. Generating a report based upon a condition
    By CaveCanem in forum Programming
    Replies: 2
    Last Post: 03-27-2014, 01:56 PM
  2. Replies: 3
    Last Post: 03-11-2013, 05:11 PM
  3. How to modify report based on input form
    By pmatush in forum Reports
    Replies: 1
    Last Post: 02-22-2013, 09:47 PM
  4. Generating Report from Form
    By mwabbe in forum Reports
    Replies: 8
    Last Post: 08-30-2010, 12:25 PM
  5. Replies: 1
    Last Post: 05-20-2009, 06:15 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