troubleshooting Question

Check if record exists in another table

Avatar of Sasha42
Sasha42 asked on
Microsoft Access
7 Comments4 Solutions528 ViewsLast Modified:
I have the following code attached to the close button to see if  a record exists in the invoice table.  Shirley, there is quicker way to determine that other than the folllowing code.  Thanks.

Private Sub cmdClose_Click()

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim rs1 As DAO.Recordset
Dim sSQL As String
Set db = CurrentDb
sSQL = "SELECT Invoices.ContractNumber" _
& " FROM Invoices" _
& " WHERE Invoices.ContractNumber=" _
& Chr(34) & Me.ContractNumber & Chr(34)

Set rs = db.OpenRecordset(sSQL)

    If rs.RecordCount = 0 Then
        MsgBox ("Not in Invoices table")
    End If

end sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 4 Answers and 7 Comments.
Join the Community
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 4 Answers and 7 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