troubleshooting Question

Better code then dcount to check for entry in table

Avatar of thandel
thandel asked on
Microsoft AccessVBA
14 Comments3 Solutions93 ViewsLast Modified:
I am using the following code with a dcount to search if an entry in a table exists... I feel like there is a more efficient way then using dcount twice.

Suggestions are appreciated.

Function ReceiptCK() As Boolean 'Check for office service and PT payment entry
   
    If DCount("*", "tClaimHistory", "ClaimNum=" & [Forms]![FPEntryQuery]![FClaimQuery]![tClaimNum] & " AND Status = ""PNT - Paid""") = 0 Then
        MsgBox "Payment (PMNT) entry needed to create a receipt", vbInformation, "Receipt"
        ReceiptCK = False
    ElseIf DCount("*", "tClaimHistory", "ClaimNum=" & [Forms]![FPEntryQuery]![FClaimQuery]![tClaimNum] & " AND Status = ""Office Service""") = 0 Then
        MsgBox "Office service (OSrv) entry needed to create a receipt", vbInformation, "Receipt"
        ReceiptCK = False
    Else
        ReceiptCK = True
    End If

End Function
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 3 Answers and 14 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 14 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros