Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2015
    Posts
    11

    Trouble with DLOOKUP in a Subform

    I am trying to look up a memo field called [Message] on a table called [Patient Contact Info Table] That has matching [MR#] and [Latest Date]. This is being done on a Subform, and the [SubformMR#] is linking the main form with the Subform.




    When I use
    =DLookUp("[Message]","[Patient Contact Info Table]","[MR#] = [SubFormMR#]" & "And [Date of Contact]=[Latest Date])
    It does not work and just return a blank

    When I use
    =DLookUp("[Message]","[Patient Contact Info Table]","[MR#] = [SubFormMR#]" & "And [Date of Contact]=#8/29/2015#")
    It works but obviously only gives me the message for that specific date

    I've tried proper reference to the subform control [Latest Date] but still not working.
    =DLookUp("[Message]","[Patient Contact Info Table]","[MR#] = [SubFormMR#]" & "And [Date of Contact]=Forms![View Patient Info Form]![New Contact Info Subform].Form![Latest Date]")
    Not sure what I am doing wrong

    [Latest Date]=Max([Date of Contact]) This gives Latest Date properly, but I can't get the DLOOKUP function to us this date. The MR# seems to be working.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    you shouldnt need Dlookup on a form.
    use the query behind the form to a bound field.

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I agree with ranman256. The memo field should be in the query.


    I did notice you have spaces and special characters in your object names.
    Code:
    =DLookUp("[Message]","[Patient Contact Info Table]","[MR#] = [SubFormMR#]" & "And [Date of Contact]=[Latest Date])
    Should use only letters, numbers and possibly the underscore.
    Instead of
    ..."MR#", I would use "MR_Num"
    ..."Date of Contact" would be "Date_of_Contact" or "DateOfContact"

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

Similar Threads

  1. Subform Requery Trouble
    By ztpkng in forum Forms
    Replies: 2
    Last Post: 06-19-2014, 04:02 PM
  2. Export / Import form and subform trouble
    By Roy Hallowell in forum Import/Export Data
    Replies: 5
    Last Post: 06-03-2014, 06:23 PM
  3. Replies: 2
    Last Post: 03-06-2013, 11:37 PM
  4. Replies: 8
    Last Post: 02-04-2013, 11:32 AM
  5. Replies: 13
    Last Post: 11-02-2012, 01:19 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