Results 1 to 6 of 6
  1. #1
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2003
    Join Date
    Jun 2016
    Posts
    237

    Dcount

    Hi to all,



    I have this VBA code that gives an error "Method or data member not found"

    Code:
    If DCount("*", "tblBorrowedBooks", "fkBookId = " & Me.txtfkBookId _
                & " AND fkMemberId = " & Me.cboMember _
                & " AND DateBorrowed=#" & Me.txtDateBorrowed & "#" _
                & " AND DateReturned=#" & Me.txtDateReturned & "#") > 0 Then
                    MsgBox "A book matching these details already exist!", vbExclamation, "Library Program"
    I don't know how to fix it.

    Khalil

  2. #2
    Join Date
    Apr 2017
    Posts
    1,673
    I think the problem is with parameter "*". This must be a single field (probably a non-null one). The best shot will be a primary key of table, but I thing any foreign key with non-null condition will do. E.g.
    Code:
    If DCount("fkBookID", "tblBorrowedBooks", "fkBookId = " & Me.txtfkBookId & ...

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Sorry, but I don't have time to work thru all of this, right now...but the problem is not with the * in

    If DCount("*"

    This is perfectly acceptable syntax for determining if a Record exists given the stated criteria.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    This appears to be a duplicate of post 7 here:

    https://www.accessforums.net/showthread.php?t=79924

    FWIW, I always use "*" in the field argument with DCount().
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Me as well!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    Join Date
    Apr 2017
    Posts
    1,673
    OK! I have never used "*" myself in DCount, so it was my 1st suspect. Otherwise only possible reason I can think of is wrongly spelled table/field name.

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

Similar Threads

  1. DCount Help
    By mpaulbattle in forum Queries
    Replies: 3
    Last Post: 11-21-2016, 11:42 AM
  2. DCount help
    By McArthurGDM in forum Programming
    Replies: 6
    Last Post: 06-15-2015, 04:30 PM
  3. DCount and If
    By Madmax in forum Access
    Replies: 3
    Last Post: 07-28-2011, 06:53 AM
  4. DCount and SQL
    By DSTR3 in forum Queries
    Replies: 3
    Last Post: 12-06-2010, 03:07 PM
  5. Help with Dcount
    By tozey in forum Programming
    Replies: 1
    Last Post: 08-10-2010, 10:53 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