Results 1 to 7 of 7
  1. #1
    blappy347 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    6

    Query to base report, multiple forms, subreports, confused

    I'm trying to create a query that will run a report of the current form. I've got it to run the current form, but that form is based off of multiple tables. The form has pk of WorkOrderID, with fk of CustomerID, FieldID (this is a location, think farming, fields with crops), and ProductID. My form is setup nicely so that you can choose a customer, field, or product from a combo box. When you click the drop down of the combo box it displays the customers first and last name, but the combo box is based off of fk CustomerID only. So when I put the query together to make the report, the report only shows the CustomerID (autonumber) instead of the first and last name of the customer. Same with field. Instead of showing the four parts that make up a fields legal unique locations (1/4, section, township, range) it only shows the first part. In my report I need it to give all the info. This also goes for the product.

    I tried to add FirstName and LastName from my CustomerT table into the query and put in criteria based off of CustomerID from the form but I'm definitely not doing it right. I tried "WHERE [WODetsQ1].[CustomerID]"=[CustomerT].[CustomerID], but then what?

    I also need to get all of the EPA info for each product on a work order to be in the report. All this info is in the ProductT table. It's a lot of info for each one, should I put that in a sub report? How do I link it to the work order?



    Any suggestions? I can post more details or include my db to look at. This is the last piece of the puzzle for my first database and I'm dying to get it done, but this is a little over my head. Any help is appreciated. Thanks.

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    if you're putting it as criteria in a query the syntax for referencing a field on a form is:

    forms!formname!fieldonform

    So let's say your form is called MAINFORM and your field is CUSTOMERID the criteria of your query would be:

    [forms]![MAINFORM]![CUSTOMERID]

    if you're doing it through building your own SQL statement it would be:

    ".... WHERE [WODETSQ1].[CustomerID] = " & forms!MAINFORM!CUSTOMERID

    if customerid is a numeric field

    ".... WHERE [WODETSQ1].[CustomerID] = '" & forms!MAINFORM!CUSTOMERID & "'"

    if customerid is a text field

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    You based the report on a query that includes the CustomerT and Fields tables by joining on the PK/FK fields?

    Need to concatenate variables into SQL string. Reference to control is a variable.

    "WHERE [WODetsQ1].[CustomerID]=" & Forms![form name here].[CustomerID],

    I don't think the EPA info needs to be a subreport but need to know more about data structure.
    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.

  4. #4
    blappy347 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    6
    I based the report on a query from the WorkOrderF form. This form has it's PK of WorkOrderID, with two FK - FieldID and CustomerID. In the subform there is another FK, ProductID. So CustomerID is used on the WorkerOderF form to also show FirstName and LastName fields from the CustomerT table, but it's still only the CustomerID field. When I run the report I only get CustomerID, and not the FirstName and LastName fields. I need names in too. Same exact scenario with Field and Product.

    The EPA info is enough to take up about a page for each product. It is organized into about 20 different fields. About half are text box and the other half are yes/no check boxes.

    It's hard for me to explain, I've attached some screenshots of the db, hopefully it will help.

    Click image for larger version. 

Name:	DB Query.jpg 
Views:	4 
Size:	104.4 KB 
ID:	11845Click image for larger version. 

Name:	DB Relationships.jpg 
Views:	3 
Size:	90.1 KB 
ID:	11847Click image for larger version. 

Name:	DB WOForm.jpg 
Views:	4 
Size:	86.0 KB 
ID:	11848

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    If CustomerT is included in the report RecordSource then the customer name info should be available. Don't know why is not, would have to analyse database.

    You have a circular relationship between FieldT, CustomerT, WorkOrderT. This might not be a good thing. http://www.codeproject.com/Articles/...atabase-Design
    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.

  6. #6
    blappy347 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    6
    So it'd be smart to remove the Field table and form and have the user just enter that into each WorkOrder to avoid the circle of death?

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Appears to me could:

    Break link between FieldT and CustomerT then remove CustomerID from FieldT

    Or

    Break link between FieldT and WorkOrderT then remove FieldID from WorkOrderT

    Just don't know enough about your data and business flow.

    Each Customer can have only one location?
    If the customer will always have the same location then put the FieldID with customer info. Then the workorder location can be determined through link with customer.

    Each workorder can have only one location?
    Or if customer can do business in multiple locations and the workorder can be for only one location then put the FieldID in workorder table.
    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. Empty Main Report, won't run subReports
    By rankhornjp in forum Reports
    Replies: 8
    Last Post: 03-15-2013, 11:07 AM
  2. Looping through a report with subreports.
    By less1die in forum Reports
    Replies: 1
    Last Post: 02-22-2013, 03:15 PM
  3. Replies: 4
    Last Post: 01-25-2013, 01:57 PM
  4. Replies: 5
    Last Post: 05-18-2011, 11:02 AM
  5. Multiple Subreports with page break
    By rayc in forum Reports
    Replies: 7
    Last Post: 09-02-2006, 06:59 PM

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