Results 1 to 7 of 7
  1. #1
    perryc is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    122

    DCount Question

    Anyone can point to me what is wrong with this statement?



    If DCount("*", "tbl_Demographic", "[DOB] = '" & Me.DOB & "'") > 0 Then
    Msgbox "NameExist"
    End If

    DOB = Date Of Birth (e.g. 7/1/1956)

    I have a Form with a field DOB but whenever I entered a new DOB, I would like it to look up if the same DOB exists in another table (Demographic)

    Thanks in advance.

    Sincerely,
    Perry

  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
    Different delimiter required for date/time fields:

    http://www.theaccessweb.com/general/gen0018.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    By the way, more than one person can have the same DOB. You might want to compare DOB and name or something.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    perryc is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    122
    That's it. Ty.

  5. #5
    perryc is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    122
    Can you give me tips on why this combo does not work?

    If DCount("*", "tbl_Demographic", "[DOB] = #" & Me.DOB & "#" & " AND " & "Patient='" & Me.[Patient] & "'") > 0 Then

  6. #6
    perryc is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    122
    never mind... I did not name the Field correctly.

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Just back from lunch; glad you got it sorted.

    Edit: you had working quotes, just more than necessary.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Another DCount
    By Thompyt in forum Programming
    Replies: 5
    Last Post: 01-18-2019, 04:30 PM
  2. DCount / DLookup Question
    By TEXEIRC in forum Programming
    Replies: 4
    Last Post: 11-01-2017, 10:26 AM
  3. Replies: 1
    Last Post: 03-30-2015, 03:08 AM
  4. Dcount question
    By alsoto in forum Forms
    Replies: 2
    Last Post: 08-29-2011, 02:30 PM
  5. Dcount question
    By jpkeller55 in forum Access
    Replies: 4
    Last Post: 02-21-2011, 11:43 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