Results 1 to 8 of 8
  1. #1
    bgwool is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2014
    Posts
    29

    Populate text box from value in query


    I am working on a report that will display how many hours each employee worked for each day in a selected time period. I have 16 text boxes in my report that I would like to associate with the user-inputted start date and end date. For example, text box 1 is associated with [StartDate], text box 2 is associated with [StartDate]+1. I need the text boxes to display a value ([TotalHours]) in a query where the date is equal to the date it is associated with, as well as the employeeID with another text box on the screen. I know I'm probably not explaining this very well, but I will try to clarify if anybody has any questions. Thank you for any help!

    In case this helps clear up my question, I want the text box to display value [TotalHours] in Query [TimeCards] where [EmployeeID] = value of a text box AND [Date] = value of a text box

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Sounds like you want to pivot the data (a CROSSTAB query). Show example raw data and example of desired output.
    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.

  3. #3
    bgwool is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2014
    Posts
    29
    This the query (Time Cards) I'm using for all data in report (much simplified, but this is the only data needed in my report:

    Name
    Date TotalHours

    John 8.15 6
    John 8.16 7
    Jim 8.16 8
    Jim 8.18 4
    Jim 8.20 7

    -------------------------
    I have a report based on the query TimeCards. It is filtered by user-inputted [StartDate] and [EndDate] to get a specific 15/16 day period.

    On the report I have a text box [EmpName] that will display each employee's name [Name]
    Then I have 16 text boxes that I would like to display the value [TotalHours] for each date in the period for the employee.

    Basically, on the 1st box I want it to display [TimeCards].[TotalHours] where [Name]=[EmpName] AND [Date]=[StartDate]
    On the 2nd box, I want it to display [TimeCards].[TotalHours] where [Name]=[EmpName] AND [Date]=[StartDate]+1
    etc., until the last box
    -----------------
    So, in this example, if the user-input [StartDate] is 8.15, I would like it to display

    John
    6 , 7 , Null, Null etc.
    Jim
    Null, 8, Null, 4, Null, 7

  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
    53,646
    Well, a CROSSTAB output would be like:
    Name 8.15 8.16 8.18 8.20
    John 6 7
    Jim 8 4 7

    There is no 8.17 column because there is no record in the sample data for 8.17.
    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
    bgwool is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2014
    Posts
    29
    The crosstab format is perfect (but I do need the dates without values to remain in the data), except that I need it to be in a report because there are specific formatting requests that I'm trying to accommodate (i'm making it for my job).

  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
    53,646
    Building a report to run perpetually based on a CROSSTAB is difficult because of their dynamic nature, especially when pivoting on date criteria and the date range of desired records constantly changes. Review http://allenbrowne.com/ser-67.html

    If you need all dates then need a dataset of all possible dates to be included in the query.
    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
    bgwool is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2014
    Posts
    29
    Do you think Dlookup could work to populate a text box? something like =Dlookup ("[TotalHours]",[TimeCardDetails],"[Date]=" & [StartDate])

  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
    53,646
    A domain aggregate is a possibility but can be slow performer.

    I have a report where I want all twelve months to display so I have twelve textboxes on report arranged vertically. Example expression:
    =Sum(IIf([MO]=7,[Revenue],0))

    [MO] is a calculated field in the report RecordSource query to extract the month value. Code opens the report filtered to a fiscal year parameter input on a form.

    You might find this thread of interest and the example db in post 60 https://www.accessforums.net/forms/g...tml#post239648

    Also, http://forums.aspfree.com/microsoft-...ry-322123.html
    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. populate text box
    By slimjen in forum Forms
    Replies: 4
    Last Post: 06-18-2014, 09:14 PM
  2. Populate subform text box
    By hilian in forum Forms
    Replies: 8
    Last Post: 12-15-2012, 07:50 PM
  3. Replies: 12
    Last Post: 06-25-2012, 01:42 PM
  4. Replies: 2
    Last Post: 06-11-2012, 09:37 AM
  5. Replies: 8
    Last Post: 05-17-2011, 04:41 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