Results 1 to 3 of 3
  1. #1
    eww is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    125

    Would DLookup() work better here?

    Longer explanation is here: https://www.accessforums.net/program...view-8186.html
    Short summary is I've got a subform in a datasheet form that pulls total weights of segments in from a totals query. I set a field in the form equal to the subform field because I can't set it directly.

    I was wondering if the DLookup function work better here for what I want to accomplish. I was thinking something along the lines of:

    Code:
    Me.DetailedWeight = DLookup("[SumOfWeight]", "qrySegmentWeights",  _
    "'[Segment] =" & Forms!sfrmSegments!Segments'" AND  _
    "'[JobNumber] =" & Forms!sfrmSegments!JobNumber'")
    But I'm not exactly sure how to write it, or if this is even a correct way of solving my problem.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Not clear on what you're doing, but to correct the syntax:

    Code:
    Me.DetailedWeight = DLookup("[SumOfWeight]", "qrySegmentWeights", "[Segment] ='" & Forms!sfrmSegments!Segments & "' AND [JobNumber] ='" & Forms!sfrmSegments!JobNumber & "'")
    which assumes both fields are text. I'd recommend getting it working all on one line, then breaking it onto multiple lines if you want. One hurdle at a time.

    Also, if that's a subform as the name implies, the syntax is off:

    Forms Refer to Form and Subform properties and controls
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    eww is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    125
    Oh you're right, I'm familiar with subform syntax I just forgot it in there. I haven't tried this code yet I was just putting it up here to see if anyone had any thoughts on the correct way to do this.

    I'm trying to have a in one form two subforms, one is for submittals, one is for segments. The segments are like categories that you can pick when entering the submittals. I'm trying to total the submittals by segment (or category) and show that total on the segments subform (which is in datasheet view). I'm attaching a picture because I'm thinking this is probably difficult to understand from my descriptions. Right now I have the weights from the submittals totaling in a query, and then I have a subform in the Segments subform that pulls in the total weights for each Segment. I then set the Detailed Weight for each Segment equal to the weight for the respective segment in the subform.

    Thanks for the help with the syntax

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

Similar Threads

  1. DLookup()
    By jgelpi16 in forum Programming
    Replies: 2
    Last Post: 09-15-2010, 07:20 AM
  2. Need help with dlookup.
    By Keith in forum Database Design
    Replies: 8
    Last Post: 05-24-2010, 06:28 PM
  3. Dlookup??
    By Vikki in forum Access
    Replies: 4
    Last Post: 02-16-2010, 07:59 AM
  4. Replies: 2
    Last Post: 11-04-2009, 09:45 PM
  5. Replies: 1
    Last Post: 01-10-2006, 12:32 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