Wrox Programmer Forums
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 3rd, 2003, 12:05 PM
Registered User
Join Date: Oct 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to echajmovic
Default Check for existing record


How do I check for an existing record in a table before attempting to enter the record. My table has 3 primary keys which are SchoolID, SchoolYearID, and TeacherID.


Old November 3rd, 2003, 08:03 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts

You could open a recordset, with those three fields as criteria, and make sure the record count is 0.
For example:

Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset( _
   "SELECT * " _
   & "FROM tblSchool " _
   & ""WHERE ((([SchoolID])=" & Me.txtSchoolID _
   & ") AND (([SchoolYearID])=" & Me.txtSchoolYearID _
   & ") AND (([TeacherID])=" & Me.TeacherID & "));"

If rst.RecordCount > 0 Then MsgBox "Data Exists"

.....or something along those lines


I am a loud man with a very large hat. This means I am in charge

Similar Threads
Thread Thread Starter Forum Replies Last Post
Add a new record between two existing records hsncompany BOOK: Beginning Access 2003 VBA 0 April 13th, 2008 03:36 PM
Check For Existing Folders & Files zandermax Access VBA 2 September 30th, 2005 11:43 AM
How to check whether a filie is existing szms VB.NET 2002/2003 Basics 2 December 6th, 2004 03:49 PM
Want to insert a new record when an existing recor lionofthejungle Access 1 September 9th, 2004 11:55 AM
check for existing records b4 insertion deian Access ASP 11 June 13th, 2004 09:01 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.